If I alter the SqlDataSource select command in code and then bind to a gridview, I run into problems. When I do a sort, next page (basically any postback), the datasource goes back to the original state. It is like the SqlDataSource is not maintained in the state. I end up having to re-alter the SqlDataSource select command on every page_load. Is this by design or is this a bug?
Is the SqlDataSource any "smarter" than doing it the old fashion way by populating a Dataset on (!IsPostBack) ? For example, if I have a bunch of data in a paged gridview, is the SqlDataSource smart enough not to bother filling the entire dataset if I don't need it for that page's display? I know the SqlDataSource provides for update/insert/delete, but I am not doing that in this application, it is just a query/report page.
Hi, I have created a search page which needs to perform different search function in same page. I have setuped a sqldatasource then manual setup the connection string and command inside the codefile. So the select command can be various depends on the event. The problem is all of those setting will be reset after I click on the pageindex in the girdview control to go to next pages. Since this gridview is linked
with this sqldatasource control, I need to restore the connection string/command when user choose decide to view next page of data inisde the gridview.
I think I must have done something wrong in here becuase it will end up retrieving the total amount of data when everytime user choose to view next or perivous page.
Hi All: I'm having problems creating a data connection between a windows 2000 server running .net 2.0 and a sql2005 server (server2003). I'm trying to create a connection in VWD2005 express, and when I use the visual wizard, I get a connection error with something about "named pipes" when I'm trying to connect using an alias on the server that uses tcp/ip (the alias is created in cliconfg). If I click on "advanced properties" in the connection, and I select "TCP/IP" for the Network Library, what's displayed is "TCP/IP (DBMSGNET)" ...but shouldn't it say "DMBSSOCN"? I'm wondering if this is correct, or a cosmetic bug in the .net sqlclient GUI, or indicative of any underlying problem that's preventing me from creating the connection? If I manually override the connection string in web.config by entering "Network Library: DBMSSOCN", I still can't connect, getting a timeout error that the sql2005 server is not responding. But I know the server is working properly, with other .NET DB connections working within the same application...so I'm thinking this must be a problem with VWD and/or the .net framework on my local computer (not the server)? I don't know where to begin to look to debug this problem?
Hey folks, Today's been way too much fun... Someone changed the name of a machine in our department and now Win2k thinks the machine's name is (for example) "Fred", but if I do a select @@servername, SQL returns (again, for example) "Barney".
The machine's name started out as "Barney".
The last time this happened, it was on an NT4 box, and we just reinstalled sql and away we went.
This time, they reinstalled sql and released the box to the team, only to find out later that reinstalling sql didn't do squat this time.
Which brings me to the question: How do I convince SQL that it's really, truly supposed to be named "Fred"? Besides that, what do I tell Wilma, Betty, Pebbles and Bamm Bamm?
I am trying to import data from Access 2000 in SQL Server 2000 usingDTS. One of the tasks requires a multi-table join but I am gettingsyntax errors if I generate the query with Build Query.With just a single join like this it works fine:FROM Tracker INNER JOINbdmanager ON Tracker.bdmanager = bdmanager.name,countryBut as soon as I get it to generate an extra join, e.g.FROM Tracker INNER JOINbdmanager ON Tracker.bdmanager = bdmanager.nameINNER JOINcountry ON Tracker.country = country.country.... I get "sytax error (missing operator)". The weird thing is that itgenerated the syntax itself!I can paste the query into Access and it works fine.Why is this happening and what's the best workaround?ThanksAndy
I've been writing stored procedures for a while, but right now I'm stumped on something. I've got this one error when I try to use OPENROWSET in my stored procedure that tells me I need to set my ANSI_NULLS and ANSI_WARNINGS, so I put SET ANSI_NULLS ON GO SET ANSI_WARNINGS ON GO into my stored procedure, I clicked check syntax (this is all in enterprise manager), it was okay, I clicked okay, it told me I needed to set those things again, so I played around some more, deleted the SET ANSI's, adding them, deleting them, moving them around, and eventually it worked after I deleted them again.
Anyone know why this happens? Where exactly are my SET ANSI_NULLS supposed to go? As a workaround I've been simply running them in the query analyzer.
I have an Excel source > Data Conversion task > OLE DB Destination.
In the Data Conversion task I rename all the outputs to match the column names in my destination table.
However, when I go to map the columns in the OLE DB Destination mapping tab, it's a mess. Some fields are prefaced by "Data Conversion" as in "Data Conversion.column1", others are prefaced by "Excel Source" and others have no prefix at all.
What's confusing is, since all the columns are going through the Data Conversion task, how come I don't have ALL fields prefaced by "Data Conversion" ?
That is, only SOME of the fields have a "Data Conversion" prefix, and some don't. The ones that aren't prefaced by "Data Conversion" have no corresponding "Excel Source" so I'm assuming that the ones without the prefix are from the Data Conversion task.
There is something very strange going on here. Tested with ADO 2.7 andMSDE/2000. At first, things look quite sensible.You have a simple SQL query, let's sayselect * from mytab where col1 = 1234Now, let's write a simple VB program to do this query back to anMSDE/2000 database on our local machine. Effectively, we'llrs.open sSQLrs.closeand do that 1,000 times. We wont bother fetching the result set, itisn't important in this example.No problem. On my machine this takes around 1.6 seconds and modifyingthe code so that the column value in the where clause changes eachtime (i.e col1 = nnnn), doesn't make a substantial difference to thistime. Well, that all seems reasonable, so moving right along...Now we do it with a stored procedurecreate procedure proctest(@id int)asselect * from mytab where col1 = @idand we now find that executingproctest nnnn1,000 times takes around 1.6 seconds whether or not the argumentchanges. So far so good. No obvious saving, but then we wouldn'texpect any. The query is very simple, after all.Well, get to the point!Now create a table-returning UDFcreate function functest(@id int) returns table asreturn(select * from mytab where col1 = @id)try calling that 1,000 times asselect * from functest(nnnn)and we get around 5.5 seconds on my machine if the argument changes,otherwise 1.6 seconds if it remains the same for each call.Hmm, looks like the query plan is discarded if the argument changes.Well, that's fair enough I guess. UDFs might well be more expensive...gotta be careful about using them. It's odd that discarding the queryplan seems to be SO expensive, but hey, waddya expect?. (perhaps theUDF is completely rebuilt, who knows)last test, then. Create an SP that calls the UDFcreate procedure proctest1(@id int)asselect * from functest(@id)Ok, here's the $64,000 question. How long will this take if @idchanges each time. The raw UDF took 5.5 seconds, remember, so thisshould be slightly slower.But... IT IS NOT.. It takes 1.6 seconds whether or not @id changes.Somehow, the UDF becomes FOUR TIMES more efficient when wrapped in anSP.My theory, which I stress is not entirely scientific, goes somethinglike this:-I deduce that SQL Server decides to reuse the query plan in thiscircumstance but does NOT when the UDF is called directly. This iscounter-intuitive but it may be because SQL Server's query parser istuned for conventional SQL i.e it can saywell, I've gotselect * from mytab WHERE [something or other]and now I've gotselect * from mytab WHERE [something else]so I can probably re-use the query plan from last time. (I don't knowif it is this clever, but it does seem to know when twotextually-different queries have some degree of commonality)Whereas withselect * from UDF(arg1)andselect * from UDF(arg2)it goes... hmm, mebbe not.... I better not risk it.But withsp_something arg1andsp_something arg2it goes... yup, i'll just go call it... and because the SP was alreadycompiled, the internal call to the UDF already has a query plan.Anyway, that's the theory. For more complex UDFs, by the way, theperformance increase can be a lot more substantial. On a big complexUDF with a bunch of joins, I measured a tenfold increase inperformance just by wrapping it in an SP, as above.Obviously, wrapping a UDF in an SP isn't generally a good thing; theidea of UDFs is to allow the column list and where clause to filterthe rowset of the UDF, but if you are repeatedly calling the UDF withthe same where clause and column list, this will make it a *lot*faster.
I want that a textbox do a postback after I change the text : I change autompostback to true , It's do a postback after I press on the enter button , how can I do automatic postback after the text change without press on the enter button?
Hi. We have a problem. The sql insert don't work together with postback on the insert button. The following solution has been sugested:Partial Class Login Inherits System.Web.UI.Page
Protected WithEvents loginButton As Button
Protected Sub loginButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles loginButton.Click Response.Redirect("Tunnel1.aspx") End Sub
End Class But it doesn't work (the data is saved in the databse but the page isn't redirected to "Tunnel1.aspx"), why? Here is the code for the page:<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" title="Untitled Page" %>
I'm working on a report having 2 date parameters(which uses calendar control) and a dropdownlist. But on selecting each of these parameters, the page refreshes. For eg On selecting a date from the calendar control results in a postback. The same is the case with the dropdownlist. Could you please help to resolve this issue? We need the postback to happen only on clicking the 'View Report' button.
Also, is there any way to customize the 'View Report' button. It always appears in the right hand side. Can we set the position of this button so that it appears just below the paging button?
Hey, I hope someone can quickly tell me what I am obviously missing for this weird problem. To give a general picture, I have an ASP.net webpage that allows users to select values from several dropdown menus and click an add button which formats and concatenates the items together into a listbox. After the listbox has been populated the users have the option to save the items via a save button. The save button parses each item in the listbox to basically de-code the concantenated values and subsequently inserts them into a table residing on a backend MSSQL 2005 database. PROBLEM: In the process of testing the application, I noted this strange behavior. If I use the webpage to insert the values, go to the table where the values are stored and delete the rows; Upon a refresh of the web page the same actions seem to be getting replayed and the items are again inserted into the table. Naturally, what I'd really like would be for the page to refresh and show that the items aren't any longer there and not the other way around. If the code that performed the insert was residing in a component that was set for postback I'd expect this type of behavior but its in the Save buttons on_click event. I have tried practically everything in effort of targeting the problem but not having much luck with it. Is this behavior practical and expected in ASP.net or has anyone ever heard of anything similar? I have never encountered this type of problem before and was hoping someone could provide some clues for resolving it. If more information is required I'd be happy to supply it. Hopefully, there's a simple explanation that I am simply unaware since I haven't experienced anything like this before. Anybody got any ideas??? Thanks.
I think it has been discussed previously that having default parameter values based on expressions, e.g. a default parameter value of =Split("Bug",",") in multiple parameters will cause a postbacl whenever a user selects different values from the list.
Is this by design? Its a bit of an annoying thing. The refreshpostback doesnt happen if you have basic defaults like ="All" but only when an expression of some sort is used in more than 1 parameter. Does RS think they are linked or something, why does it need to psotback efresh?
i have a report that include a parameter of type date and it is visible to the user in order to choose the date and submit view report button to rendering the report.
i don€™t know if it is a bug in SSRS or not
but the problem is that if the user try to click on the date button of the parameter and choose a date
And then try to click again on the date button and choose a date another date .....after repeat the previous step more than one time the page is post back and reset the report and this not desirable by our client
Note:
Again the date button I am mention is the date button that auto generated by the SSRS as there is a parameter of type date
This Case happen only if the report run through a browser
I have a report which includes two fields of type date pFromDate and pEndDate. My pFromDate Available values is 'No-queried', and Default values is 'Null'. My pEndDate values is 'No-queried', and Default values is the expression '=DateValue(Today)'. After I upload my report to the report server and run it pEndDate is disabled until I choose value to pFromDate and a postBack occurs. I want pEndDate display the evaluated expression automatically when I run the report. How can I do it? Thanks in advance.
I have a simple gridview that loads on page load. It uses an on page sqldatasource declaration in which there's a parameter in which value is already available in cookies. I added an asp:HiddenField and set that value on PageLoad() to the value of the cookies. I then set a FormParameter in the sqldatasource mapped to that hidden field. However that appears to have no effect at all. I'm guessing the sqldatasource will only use the form field after postback.
I am working on a report (in 2005 version) having 6 date parameters ( which uses calendar control). When on selecting the date parameter(except the last data paramenter), the page refreshes. For eg On selecting a data from the calendar control results in a postback. but if I select the last data paramenter, the page is not refreshed.
I did another test on a report that only has 2 data paramters (use the calendar control), it is the same. you select the second the data parameter, no postback happened, but if you select the first data parameter, the postback happened.
Dose anybody know what is the issues? We need the postback to happen only on clicking the 'View Report' button.
I have set up a 'Parameters' table that solely stores all pre-assigned selection values for a webform. I customized a stored query to Select the values from the Parameters table. I set up the webform. The result is that the form1.apsx automatically populates each DropDownList task with the pre-assigned values from the 'Parameters' table (for example, the stored values in the 'Parameters' table 'Home', 'Business', and 'Other' populate the drop down list for 'Type'). The programming to move the selected data from form1.aspx to a new table in the SQL database perplexes me. If possible, I would like to use the form1.aspx to Postback (or Insert) the "selected" data to a *new* column in a *new* table (such as writing the data to the 'CustomerType' column in the 'Customers' table; I clearly do not want to write back to the 'Parameters' table). Any help to get over this hurdle would be deeply appreciated.
What is the C# code I use to do this? I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.
i am using visual web developer 2005 with SQL Express 2005 with VB as the code behindi have one database and three tables in itfor manipulating each table i am using separate SqlDataSource() is it sufficient to use one SqlDataSource() for manipulating all the three tables ? i am manipulating all the tables in the same page only please help me
I have an asp:sqldatasource which is bound to a gridviewIn addition to this I would like it to a) see if there is a specif row/ item in it (ie item_id = 10 for any of the rows it has received) as I conditionally want to show another item outside of the gridview subject to if it is in the gridview or notb) show the sum of all the values within a certain column of returned rowsMany thanks
How do I get the result of this select into a variableDim sqldsFindUserId As SqlDataSource = New SqlDataSource sqldsFindUserId.ConnectionString = ConfigurationManager.ConnectionStrings("bluConnectionString2").ToString sqldsFindUserId.SelectCommandType = SqlDataSourceCommandType.Text Dim myUserIdCmd As String = "select pkUser from tblUsers where strDisplayName='" + myDisplayname + "" sqldsFindUserId.SelectCommand = myUserIdCmd ' The result of this select statement is to be stored in a variable, how do I do it?
hi all, in all my 2.0 learnings and books i keep coming across the page element <asp:sqldatasource>. I have always (in 1.1) used server side connections and adapters to bind my Sql datasets to any control needed. Now that im learning 2.0 im finding it difficult to understand using control on the page to bind my data. Can someone explain the benefits of using this data source? Ideally i would like to keep my data access layer separate from my presentation layer but i'd really like to understand why this method seems so popular. thanks in advance, mcm
Hi, I am new to ASP.NET 2.0 and I am trying to use VWB to bind my web site to a SQL Express edition. I used SQLDataSource to specify the .mdf file so I can connect to my tables but when I click on the advanced button to generate the Insert, Update, Delete SQL I find it grayed out and it cannot be clicked. I looked into several tutorials online and I couldn't find the problem, can anyone explain what I am missing or doing wrong? Any suggestion is very appreciated. Thanks
SELECT * FROM [CONTACTS] WHERE @ddl_value LIKE '%@txt_value%'
Why doesn't this not working I am using SQLdatasource control to bind a gridview If my query is wrong then what might be the correct one to work with like operator in the sqldatasource Can any ony help me!
Hello All, I have quick question .. In my aspx page i have gridview and Sql DataSource object as you can see <asp:sqldatasource id="SqlDataSource1" runat="server" ></asp:sqldatasource>
<asp:gridview id="GridView1" runat="server" allowpaging="True" allowsorting="True" autogeneratecolumns="False" datasourceid="SqlDataSource1"> <columns> <asp:boundfield datafield="breakdownid" headertext="breakdownid" insertvisible="False" readonly="True" sortexpression="breakdownid" /> <asp:boundfield datafield="ticketno" headertext="ticketno" sortexpression="ticketno" /> <asp:boundfield datafield="systemtype" headertext="systemtype" sortexpression="systemtype" /> <asp:boundfield datafield="break_date" headertext="break_date" readonly="True" sortexpression="break_date" /> <asp:boundfield datafield="subject" headertext="subject" sortexpression="subject" /> <asp:boundfield datafield="status" headertext="status" sortexpression="status" /> <asp:boundfield datafield="prioritylevel" headertext="prioritylevel" sortexpression="prioritylevel" /> <asp:boundfield datafield="mobiletype" headertext="mobiletype" sortexpression="mobiletype" /> </columns> </asp:gridview> In codebehind file i call a function to get data from database. what i want is to bind the result to the sqlDataSourse not the gridview. I need to have the SqlDataSourse thier.. Any help please
Sub Page_load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim objReader As New Dynamic.Reportsdemo SqlDataSource1 = .objReader.Get_Tickets(1, 0, "all")
I am trying to get record from a table and verify it with a textbox i have a sqldatasource. i have a text box called txtEmail and this is my Select command. how can i get this working if its possible ? something like txtEmail.text = SqlDataSource1.Secect then ... my code. (i dont know if this a correct way to do this) <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:imacstestConnectionString %>" SelectCommand="SELECT FROM [t_CustomerAcct]"
hi all,i am using sqldatasource for gridviewso that i can edit and update any row at the same place ..... and not to write any code for that....now later on if i wanna change the selectcommand of that sqldatasource how can i ? so that the edit and update will be same as it was....
Hi, I'm trying to go through a checkbox list and inserting them into a database using a sqldatasource with the following code:For Each li As ListItem In Locations_Checkbox.Items If li.Selected = True Then
Dim DataSource2 As SqlDataSource = CType(InsertProgrammeLocations, SqlDataSource) DataSource2.InsertParameters.Add("ProgrammeID", li.Value) DataSource2.Insert()
End If Next When more than one checkbox is ticked, I'm getting the error 'The variable name '@ProgrammeID' has already been declared'. How do I close or reset my Datasource before I try and use it again? Thanks for your help