Lets say I have a Sqldatasource that uses the following SelectCommand="SELECT category,name FROM table". How do I get the value on category from my datasource in code behind if I know that my selectcommand always will return one row? Can I write something like datasource.items["category"].Value?
hi to all,i am kinda crazy now... i have this problem regarding codebehind codes... i am kinda still a beginner...can you please give me an example of codebehind codes in which selectcommand (and other commands) in sqldatasource to be written in aspx.vb not on aspx..on how to execute it and so as its parameters...i know that those commands are easy to configure on aspx page... but there some reasons why i need to put it in aspx.vb page... so is there any way...? is my problem clear?hoping for a reply asap.. thank you...
I am trying to use the SQLDataSource from the codebehind. However, I have a problem accessting the ConnectionString.I declare my connection string in my web.config file, and I declare this as:Dim DBConn As New SqlConnection(ConfigurationManager.ConnectionStrings("DbConnString").ConnectionString)My problem arises though when I get to the SQLDataSource. How can I reference DBConn via the SQLDataSource.ConnectionString?Karls
Hi, I have a SQLDataSource, button, textbox, and label. I take the text from the textbox, count it's occurance in the database, then assign the number to the label. The code works but I would like to provide a button that will execute/invoke the SQLDataSource. I have this in the click event for the button: Me.label1.Text = SqlDataSource1.Select(DataSourceSelectArguments.Empty) How do I execute a SQLDataSource from the code-behind for the button click event? Thanks.
Hello...Can someone help me?I´m getting info of a product via sqldatasource in this way:<asp:SqlDataSource ID="myData" runat="server" ConnectionString="..." SelectCommand="spGetProduct" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:QueryStringParameter Name="Id" QueryStringField="Id" Type="String" /> </SelectParameters></asp:SqlDataSource>In my ASPX page I get the data in this way:<asp:Repeater ID="repProduct" runat="server" DataSourceID="myData"> <ItemTemplate> <p><%# Eval ( "ProductName") %></p> </ItemTemplate></asp:Repeater> My problem is in my code behind because I need some data from this DataSource.For example, I want the Product Name as the page title. So the question is how I get something like this in my code behind:protected void Page_Load ( object sender, EventArgs e ){ this.Page.Title = Eval ( "ProductName") ;}Thanks!
Hi, I don't know if i's a silly question. Now I want to get data from sqldatasource by only write some code,I don't know without creat some data control components if it can be true? If it can do,how can I write the codes? Especially I don't know how to write the code witch can "read" data.
Hey All, I'm very new to ASP.NET and have recently begun using the databinding functionality. So far, all I've had to do is drag and drop the various controls and then use the data source wizard to set up an appropriate query. However, now I've got a bit of a different need. In the VB codebehind, i need to be able to ask whether something is true in the database, and then if it is, carry out functions. So, for example, what I need to do is: if (SQLStatement "Select charttype FROM charts WHERE datasource = " & dropdownlist1.selecteditem.tostring()) Then 'do whatever end if Trouble is, I don't know how I would go about binding the data so that I could access it in this way. Any guidance would be very much appreciated. Thanks,J Rankin
Hi Folks, How can i pass a string variable from code behind page to html page on event fire. i want to pass sql qerry to SelectCommand (SELECT * FROM [Tickets] WHERE ([TicketNo] = @TicketNo)) in some variable from codebehind on some event fire. <asp:SqlDataSource ID="sqldsTickets" runat="server" ConnectionString="<%$ ConnectionStrings:IMTicketingConnectionString %>" SelectCommand="" > <SelectParameters> <asp:SessionParameter Name="TicketNo" SessionField="test" Type="Int64" /> </SelectParameters> </asp:SqlDataSource> Thanks in advance
This is probably an easy one. What is best way to determine if a SqlDataSource is empty (i.e. the query produced no results) in the CodeBehind? I'm using this: if (SqlDataSource1.SelectCommand.Contains(String.Empty)) { //Add code for scenario here. } It seems to work, but something just doesn't feel right about it for some reason. Thanks
I have a database with columnsuserOwnListsuserID uniqueidentifieruserName nvarchar100userList nvrachar100createdDateI have created successfully a gridview controller to edit these values in database. The Gridview data is populated by SqlDataSource.I have also created a EmptyDataTemplate and created a form into it. There is only one textBox and submit button to create the First entry to userOwnLists -table.Now I collect the value from EmptyDataTemplate textbox with id userList1 and create a codebehind logic for the submitbutton.protected void Button2_Click(object sender, EventArgs e) { TextBox listName = (TextBox)this.FindControl("listName1", GridView1.Controls);SqlDataSource1.InsertParameters["userId"].DefaultValue = Membership.GetUser().ProviderUserKey; SqlDataSource1.InsertParameters["userName"].DefaultValue = Membership.GetUser().UserName.ToString(); SqlDataSource1.InsertParameters["listName"].DefaultValue = listName.Text; SqlDataSource1.InsertParameters["createdDate"].DefaultValue = DateTime.Now.ToString(); SqlDataSource1.Insert(); }The problem is now that I get error: Exception Details: System.Data.SqlClient.SqlException: Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.OK. So I Googled a bit and found this:http://scottonwriting.net/sowblog/posts/4690.aspxMy Question is: How do I convert userId so I can insert it to database successfully?This does not work:String userId = Membership.GetUser().ProviderUserKey.ToString(); SqlDataSource1.InsertParameters["userId"].DefaultValue = Convert.ToString(userId);
Hi, I am a newbie in using ASP.NET 2.0 and ADO.NET. I wrote a hangman game and want to record statistics at the end of each game. I will create and update records in the database for each authenticated user as well as a record for the Anonymous, unauthenticated user. After a win or loss has occurred, I want to programmatically use the SQLDataSource control to increment the statistics counters for the appropriate record in the database (note I don't want to show anything or get user input for this function). I need a VB.NET codebehind example that will show me how I should set up the parameters and update the appropriate record in the database. Below is my code. What happens now is that the program chugs along happily (no errors), but the database record does not actually get updated. I have done many searches on this forum and on the general Internet for programmatic examples of an update sequence of code. If there is a tutorial for this online or a book, I'm happy to check it out. Any help will be greatly appreciated. Lambanlaa CODE - Hangman.aspx.vb 1 Protected Sub UpdateStats()2 Dim playeridString As String3 Dim gamesplayedInteger, gameswonInteger, _4 easygamesplayedInteger, easygameswonInteger, _5 mediumgamesplayedInteger, mediumgameswonInteger, _6 hardgamesplayedInteger, hardgameswonInteger As Int327 8 ' determine whether player is named or anonymous9 If User.Identity.IsAuthenticated Then10 Profile.Item("hangmanplayeridString") = User.Identity.Name11 Else12 Profile.Item("hangmanplayeridString") = "Anonymous"13 End If14 15 playeridString = Profile.Item("hangmanplayeridString")16 17 ' look up record in stats database18 Dim hangmanstatsDataView As System.Data.DataView = CType(statsSqlDataSource.Select(DataSourceSelectArguments.Empty), System.Data.DataView)19 20 gamesplayedInteger = 021 gameswonInteger = 022 easygamesplayedInteger = 023 easygameswonInteger = 024 mediumgamesplayedInteger = 025 mediumgameswonInteger = 026 hardgamesplayedInteger = 027 hardgameswonInteger = 028 29 If hangmanstatsDataView.Table.Rows.Count = 0 Then30 31 ' then create record with 0 values32 statsSqlDataSource.InsertParameters.Clear() ' don't really know what Clear does33 statsSqlDataSource.InsertParameters("playerid").DefaultValue = playeridString34 statsSqlDataSource.InsertParameters("GamesPlayed").DefaultValue = gamesplayedInteger35 statsSqlDataSource.InsertParameters("GamesWon").DefaultValue = gameswonInteger36 statsSqlDataSource.InsertParameters("EasyGamesPlayed").DefaultValue = easygamesplayedInteger37 statsSqlDataSource.InsertParameters("EasyGamesWon").DefaultValue = easygameswonInteger38 statsSqlDataSource.InsertParameters("MediumGamesPlayed").DefaultValue = mediumgamesplayedInteger39 statsSqlDataSource.InsertParameters("MediumGamesWon").DefaultValue = mediumgameswonInteger40 statsSqlDataSource.InsertParameters("HardGamesPlayed").DefaultValue = hardgamesplayedInteger41 statsSqlDataSource.InsertParameters("HardGamesWon").DefaultValue = hardgameswonInteger42 43 statsSqlDataSource.Insert()44 End If45 46 ' reread the record to get current values47 hangmanstatsDataView = CType(statsSqlDataSource.Select(DataSourceSelectArguments.Empty), System.Data.DataView)48 Dim hangmanstatsDataRow As System.Data.DataRow = hangmanstatsDataView.Table.Rows.Item(0)49 50 ' set temp variables to database values51 gamesplayedInteger = hangmanstatsDataRow("GamesPlayed")52 gameswonInteger = hangmanstatsDataRow("GamesWon")53 easygamesplayedInteger = hangmanstatsDataRow("EasyGamesPlayed")54 easygameswonInteger = hangmanstatsDataRow("EasyGamesWon")55 mediumgamesplayedInteger = hangmanstatsDataRow("MediumGamesPlayed")56 mediumgameswonInteger = hangmanstatsDataRow("MediumGamesWon")57 hardgamesplayedInteger = hangmanstatsDataRow("HardGamesPlayed")58 hardgameswonInteger = hangmanstatsDataRow("HardGamesWon")59 60 ' update stats record61 'statsSqlDataSource.UpdateParameters.Clear()62 'statsSqlDataSource.UpdateParameters("playerid").DefaultValue = playeridString63 64 If Profile.Item("hangmanwinorloseString") = "win" Then65 66 statsSqlDataSource.UpdateParameters("GamesPlayed").DefaultValue = gamesplayedInteger + 167 statsSqlDataSource.UpdateParameters("GamesWon").DefaultValue = gameswonInteger + 168 Select Case Profile.Item("hangmandifficultyInteger")69 Case 170 statsSqlDataSource.UpdateParameters("EasyGamesPlayed").DefaultValue = easygamesplayedInteger + 171 statsSqlDataSource.UpdateParameters("EasyGamesWon").DefaultValue = easygameswonInteger + 172 Case 273 statsSqlDataSource.UpdateParameters("MediumGamesPlayed").DefaultValue = mediumgamesplayedInteger + 174 statsSqlDataSource.UpdateParameters("MediumGamesWon").DefaultValue = mediumgameswonInteger + 175 Case 376 statsSqlDataSource.UpdateParameters("HardGamesPlayed").DefaultValue = hardgamesplayedInteger + 177 statsSqlDataSource.UpdateParameters("HardGamesWon").DefaultValue = hardgameswonInteger + 178 End Select79 80 81 ElseIf Profile.Item("hangmanwinorloseString") = "lose" Then82 83 statsSqlDataSource.UpdateParameters("GamesPlayed").DefaultValue = gamesplayedInteger + 184 Select Case Profile.Item("hangmandifficultyInteger")85 Case 186 statsSqlDataSource.UpdateParameters("EasyGamesPlayed").DefaultValue = easygamesplayedInteger + 187 Case 288 statsSqlDataSource.UpdateParameters("MediumGamesPlayed").DefaultValue = mediumgamesplayedInteger + 189 Case 390 statsSqlDataSource.UpdateParameters("HardGamesPlayed").DefaultValue = hardgamesplayedInteger + 191 End Select92 End If93 94 statsSqlDataSource.Update()95 96 End Sub97 CODE - Hangman.aspx 1 <asp:SqlDataSource ID="statsSqlDataSource" runat="server" ConflictDetection="overwritechanges" 2 ConnectionString="<%$ ConnectionStrings:lambanConnectionString %>" DeleteCommand="DELETE FROM [Hangman_Stats] WHERE [PlayerID] = @original_PlayerID AND [GamesPlayed] = @original_GamesPlayed AND [GamesWon] = @original_GamesWon AND [EasyGamesPlayed] = @original_EasyGamesPlayed AND [EasyGamesWon] = @original_EasyGamesWon AND [MediumGamesPlayed] = @original_MediumGamesPlayed AND [MediumGamesWon] = @original_MediumGamesWon AND [HardGamesPlayed] = @original_HardGamesPlayed AND [HardGamesWon] = @original_HardGamesWon" 3 InsertCommand="INSERT INTO [Hangman_Stats] ([PlayerID], [GamesPlayed], [GamesWon], [EasyGamesPlayed], [EasyGamesWon], [MediumGamesPlayed], [MediumGamesWon], [HardGamesPlayed], [HardGamesWon]) VALUES (@PlayerID, @GamesPlayed, @GamesWon, @EasyGamesPlayed, @EasyGamesWon, @MediumGamesPlayed, @MediumGamesWon, @HardGamesPlayed, @HardGamesWon)" 4 OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT PlayerID, GamesPlayed, GamesWon, EasyGamesPlayed, EasyGamesWon, MediumGamesPlayed, MediumGamesWon, HardGamesPlayed, HardGamesWon FROM Hangman_Stats WHERE (PlayerID = @playerid)" 5 UpdateCommand="UPDATE [Hangman_Stats] SET [GamesPlayed] = @GamesPlayed, [GamesWon] = @GamesWon, [EasyGamesPlayed] = @EasyGamesPlayed, [EasyGamesWon] = @EasyGamesWon, [MediumGamesPlayed] = @MediumGamesPlayed, [MediumGamesWon] = @MediumGamesWon, [HardGamesPlayed] = @HardGamesPlayed, [HardGamesWon] = @HardGamesWon WHERE [PlayerID] = @original_PlayerID AND [GamesPlayed] = @original_GamesPlayed AND [GamesWon] = @original_GamesWon AND [EasyGamesPlayed] = @original_EasyGamesPlayed AND [EasyGamesWon] = @original_EasyGamesWon AND [MediumGamesPlayed] = @original_MediumGamesPlayed AND [MediumGamesWon] = @original_MediumGamesWon AND [HardGamesPlayed] = @original_HardGamesPlayed AND [HardGamesWon] = @original_HardGamesWon"> 6 <DeleteParameters> 7 <asp:Parameter Name="original_PlayerID" Type="String" /> 8 <asp:Parameter Name="original_GamesPlayed" Type="Int32" /> 9 <asp:Parameter Name="original_GamesWon" Type="Int32" /> 10 <asp:Parameter Name="original_EasyGamesPlayed" Type="Int32" /> 11 <asp:Parameter Name="original_EasyGamesWon" Type="Int32" /> 12 <asp:Parameter Name="original_MediumGamesPlayed" Type="Int32" /> 13 <asp:Parameter Name="original_MediumGamesWon" Type="Int32" /> 14 <asp:Parameter Name="original_HardGamesPlayed" Type="Int32" /> 15 <asp:Parameter Name="original_HardGamesWon" Type="Int32" /> 16 </DeleteParameters> 17 <UpdateParameters> 18 <asp:Parameter Name="GamesPlayed" Type="Int32" /> 19 <asp:Parameter Name="GamesWon" Type="Int32" /> 20 <asp:Parameter Name="EasyGamesPlayed" Type="Int32" /> 21 <asp:Parameter Name="EasyGamesWon" Type="Int32" /> 22 <asp:Parameter Name="MediumGamesPlayed" Type="Int32" /> 23 <asp:Parameter Name="MediumGamesWon" Type="Int32" /> 24 <asp:Parameter Name="HardGamesPlayed" Type="Int32" /> 25 <asp:Parameter Name="HardGamesWon" Type="Int32" /> 26 <asp:Parameter Name="original_PlayerID" Type="String" /> 27 <asp:Parameter Name="original_GamesPlayed" Type="Int32" /> 28 <asp:Parameter Name="original_GamesWon" Type="Int32" /> 29 <asp:Parameter Name="original_EasyGamesPlayed" Type="Int32" /> 30 <asp:Parameter Name="original_EasyGamesWon" Type="Int32" /> 31 <asp:Parameter Name="original_MediumGamesPlayed" Type="Int32" /> 32 <asp:Parameter Name="original_MediumGamesWon" Type="Int32" /> 33 <asp:Parameter Name="original_HardGamesPlayed" Type="Int32" /> 34 <asp:Parameter Name="original_HardGamesWon" Type="Int32" /> 35 </UpdateParameters> 36 <InsertParameters> 37 <asp:Parameter Name="PlayerID" Type="String" /> 38 <asp:Parameter Name="GamesPlayed" Type="Int32" /> 39 <asp:Parameter Name="GamesWon" Type="Int32" /> 40 <asp:Parameter Name="EasyGamesPlayed" Type="Int32" /> 41 <asp:Parameter Name="EasyGamesWon" Type="Int32" /> 42 <asp:Parameter Name="MediumGamesPlayed" Type="Int32" /> 43 <asp:Parameter Name="MediumGamesWon" Type="Int32" /> 44 <asp:Parameter Name="HardGamesPlayed" Type="Int32" /> 45 <asp:Parameter Name="HardGamesWon" Type="Int32" /> 46 </InsertParameters> 47 <SelectParameters> 48 <asp:ProfileParameter Name="playerid" PropertyName="hangmanplayeridString" /> 49 </SelectParameters> 50 </asp:SqlDataSource>
I have a stored procedure that returns a resultset AND an output parameter, pseudocode:myspGetPoll@pollID int,@totalvoters int outputselect questionID,question from [myPoll] where pollID=@pollID @totalvoters=(select count(usercode) from [myPoll] where pollID=@pollID)1. In my code behind I'd like to read both the rows (questionID and question) as well as total results (totalvoters) How could I do so?2. what would be the signature of my function so that I can retreive BOTH a resultset AND a single value?e.g.: private function getPollResults(byval pollID as integer, byref totalvoters as integer) as datasetwhile reader.read dataset.addrow <read from result>end whiletotalvoters=<read from result>end functionThanks!
I working on a form using an SQL DataSource. I am going to add a where clause. In that where clause a value from a label will be passed from the user. How do I pass to the HTML Source the label value from the where clause. The value can change from user to user. Sample below: SELECT [KeyRolesID], [KeyRolesDesc] FROM [KeyRoles] WHERE ([JobCodeFamily] = @JobCodeFamily). I want to replace the @JobCodeFamily which is currently coded with a value from the Sql DataSource in the design form with a label value entered by the user.
but it doesn't work, I tried use a pure asp.net web service and it works. can anyone help me to set the connecting string for datasource and query for dataset when it using wcf as the web service? Thanks in advance.
I have a question about the datasource that we create on the Report Manager. What is it used for? In the below connection string which is given in the "Connection String" text box of a datasource link:
What is this datasource used for? Is it used only to use the ReportServer database or even our queries incorporated in the RDL files will be run against this datasource? I think the latter should not happen because while creating RDL files also, we provide a connection string to run the stored procedures against that datasource.
Please let me know about the same.
Thanks a lot and let me know if the question is not clear.
I have this web store that I have been creating. When a customer goes to check out, he has to log in, then he is redirected to a page where he can view/add/or edit shipping and billing address. I have based all the sql statements on the profile username, adding records and retrieving them works just fine. When I go to change something in the info it uses an sql statement that updates based on "Where AccountUserName = @AccountUserName", I have @AccountUserName set to Profile("Username"). Keep in mind this works fine for adding new or bring up current records. I even put in code in the updated event for the sql data source to post a msgbox telling me how many rows were affected, it says 1 even though I dont see any change in the data. What am I doing wrong here, it's driving me nuts, its just a very simple update.
My god.All I want to do is post the contents of a web form to a database sql express 2005 or access using C#. Why can I find nothing for this very simple process online?Can you tell I am totally frustrated? So lets say i have a few text fields and I want to click submit and have that entered into a table. I use C# for code behind. So I can do basic C# programming and I can to webforms with visual web developer 2005 dragging and dropping for textboxs and a button to the aspx page. But then the mystery begins for me. How the hell do I simple post that form data to the table. I understand connection string basics. I aslo can design and create tables. But tying this all together is becoming a problem. I don't want to use gridview formview detailview or any of that canned UI stuff. I also don't understand VB and when I see VB examples they only cloud my already cloud ASP.NET world. Please help by posting examples, and maybe some links or books to add to my newbish collection. Thanks,Frank
Hi there, I'm using a Repeater at the moment which is bound to a SQLDataSource. I expect much load on that Website, should I choose another DataSource? Which other DataSource is better if it's about Performance? I read some stuff about the SQLAdapter and a DataSet.. is that better in performance? Why is it better? What about LinQ? Thanks a lot for any clarification.
I am using a SQLDatasource to populate a dataview as illustrated below. I run into a problem when I search for a "LastName" that includes an (') Apostrophe ( e.g. O'Reilly) . Searchin for the whole name there is no problem, but when I search for simply O, or O' I get errors. I am not sure ...when to address names with an apostrophe... 1) On insertion to the database (using a "Replace(LastName, "'", "''") 2) or after they have been entered and they are to be searched for. If scenario 1, can anyone provide the best way to do this...If scenario 2, how would that be worked into the SQL Datasource code below.... I have tried several variations with the times SQL Datasource to no avail.... I would appreciate any help ! Thanks ! <asp:SqlDataSource ID="SqlDataSource1" runat="server"ConnectionString="<%$ ConnectionStrings:ClinicTest2ConnectionString1 %>" SelectCommand="SELECT [PatientID], [Accession], [FirstName], [LastName], [Address1], [City], [strddlPatientState], [ZIP], [DOB] FROM [ClinicalPatient] WHERE [LastName] LIKE @LastName ORDER BY [LastName],[FirstName]ASC">
I have a single variable to be utilitized in my SQL Where clause... Select *FROM projectsWhere project_id = @id How do I use this c# variable in the datasource? string TableID; TableID = "192.AB"; I know this is simple, but I figured I'd ask. I don't want to do a work around , like a hidden textbox with the value assigned, and then link the datasource to the tb control, seems extremely hackish.
Hi When I try to configure a SQL datasource and I use a Microsoft SQL Server datasource I get a blank drop down list for server name. My aspnetdb is available in SQL Server 2005 and I can log into it through management studio, and the service is started. I am also using Vista Ultimate. Is there any other configuration I need to do for Visual Studio 2008 to see the SQL Server instance? Thanks Kwis
hi... i am very new to SQL server.. previously was using MySQL... now i am trying to connect my project to SQL Server.. but i wasnt able to... i keep getting errors
System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified at System.Data.Odbc.OdbcConnection.Open() at icms.DB.q(String mySTR) in C:icmsDB.vb:line 30
below is my webconfig i am not very sure about the value for the user.. because if it is MySQL i can get it from my control centre.. but what about SQL server ? where should i get my value ?
Dim myCMD As New SqlCommand Public Sub New() Dim db_server = AppSettings("db_server") Dim db = AppSettings("db") Dim db_user = AppSettings("db_user") Dim db_pwd = AppSettings("db_pwd") Dim DBConnection As String = "DRIVER={SQL Server};" & _ '<==== is my driver correct? "SERVER=" & db_server & ";" & _ "DATABASE=" & db & ";" & _ "UID=" & db_user & ";" & _ "PASSWORD=" & db_pwd & ";" & _ "OPTION=3;" myDB.ConnectionString = DBConnection myCMD.Connection = myDB End Sub 'Public Function q(ByVal mySTR As String) As OdbcDataReader 'SQL Query Public Function q(ByVal myStr As String) As SqlDataReader myCMD.CommandText = myStr Try myDB.Open() q = myCMD.ExecuteReader(Data.CommandBehavior.CloseConnection) Catch ex As Exception Err(ex.ToString) End Try
End Function Public Sub c(ByVal mySTR As String) ' COMMAND ONLY Try myCMD.Connection.Open() myCMD.CommandText = mySTR myCMD.ExecuteNonQuery() myCMD.Connection.Close() Catch ex As Exception Err(ex.ToString) End Try End Sub
If I add this to my web config ConnectionStrings section:<add name="SQLPubs" connectionString="myServer99;uid=MyUId;pwd=MyPWD;database=MyDB" providerName="System.Data.SqlClient" />Everything displays correctly, referring to this section in the SQLDataSource ControlHowever, if I add the connection string, exactly as it's listed in the web.config, and INSTEAD of the using that entry, enter it implicitly in the Connectionstring property of the DataSource Control, along with adding the System.Data.SQLClient to the ProviderName property of the DataSource control (which I understood was possible), I get this error:Unable to find the requested .Net Framework Data Provider. It may not be installedWhat am I missing?here's my tag:<asp:SQLDataSource ID="DS1" Runat="Server" SelectCommand = "SELECT top 50 {FieldList}From {TableName}" ConnectionString="myServer99;uid=MyUId;pwd=MyPWD;database=MyDB" ProviderName="System.Data.SQLClient"></asp:SQLDataSource>
im using this datasource to extract values from a database.i simply want to extract the values for ratingsum and ratingcount to populate variables so as to be checked within a code loop.how do i do this? in classis asp would be something like <%=rsRecords(RatingSum)%><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" ProviderName="<%$ ConnectionStrings:MyConnectionString.ProviderName %>" SelectCommand="SELECT SUM(rating) As RatingSum, COUNT(*) As RatingCount FROM tbl_Rating WHERE Itemid=100"> </asp:SqlDataSource>
I have a simple form that accepts a zip code and a city when the submit button is hit this is triggered... Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click Dim Zip, City As String Zip = txtZip.Text City = txtCity.Text grdZipCodes.DataSourceID = "ZipSearch" ZipSearch.SelectParameters("ZipCode").DefaultValue = Zip ZipSearch.SelectParameters("City").DefaultValue = City grdZipCodes.DataBind() End Sub This is supposed to populate a gridview with filtered data. Instead I get nothing, even though in query analyzer if I dont provide a city or a state all results are returned. Is there a reason my gridview is not populating.
New to databases so need some help. While trying to set up data source in control panel, I find that there are no drivers for *mdf files. Just *.dbo and *.xls and others. Can someone tell me what to do. I can't get analysis services to let me access my database, which are *mdf files a friend sent me.
I am trying to do incremental extract using Datasource reader. I need to send a variable in where condition to extract the data base on the max date from other table.
To implement this i have created two variables 1)to get the max date from the table. 2)to store the sql query and send the mad date from other variable to extract the data.
i have give this sql variable in data flow expression.but its not working.
I am using SSRS 2005 (Report Designer), and in 1 of the Report, I have a Report Parameter for example say IMask (Dropdown List), which I am populating by values from the following XML file (Imask.xml)
2) If no nodes(<INVALIDMASK>) are present in the XML file, I get no results when the above XML query is fired. So, Is there any way of getting the count of rows returned by XML query. And in case of no rows I want my Report Parameter (IMask) to have €śvalue field€?= NONE and €ślabel field€?= NONE
I create a datagrid and bind a datasource to it. now, i want to know how do one add new rows to the data source, so in the datagrid, i can add new rows and how to provide autonumbering.