SQLDataSource In Codebehind??

Apr 17, 2006

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

View 1 Replies


ADVERTISEMENT

Sqldatasource.. Codebehind.. Help

May 13, 2008

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... 

View 4 Replies View Related

Execute SQLDataSource From Codebehind

Mar 4, 2008

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.

View 2 Replies View Related

How Get Data From SqlDataSource Into CodeBehind?

Apr 6, 2008

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! 

View 2 Replies View Related

Can I Get Data From Sqldatasource With Codebehind?

Apr 13, 2008

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.

View 3 Replies View Related

Getting Results From Sqldatasource In Codebehind

Dec 2, 2005

(New to ASP.net 2.0 and database connection)
 
I have created an sqldatasource on the aspx page, which works fine, but how do I get the results from it in the codebehind?

View 2 Replies View Related

Check If SqlDataSource Is Empty In CodeBehind

Feb 10, 2006

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

View 2 Replies View Related

Error Inserting UserId In Codebehind Using SqlDataSource.insert()

Feb 9, 2006

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);

View 2 Replies View Related

VB.NET Codebehind Code To Update SQL Server 2005 Using SQLDataSource Control?

Jul 20, 2007

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>
 

View 2 Replies View Related

Get Value From Datasource In Codebehind

Apr 23, 2007

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? Thanks for your help! 

View 1 Replies View Related

Setting Up/accesing Database In VB Codebehind

Jul 9, 2006

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  

View 1 Replies View Related

String Variable From CodeBehind To Html

Dec 3, 2007

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

View 4 Replies View Related

Read Rows AND An Output Parameter From Codebehind Returned By Stored Proc?

Feb 5, 2008

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!

View 2 Replies View Related

SELECT A Single Row With One SqlDataSource, Then INSERT One Of The Fields Into Another SqlDataSource

Jul 23, 2007

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.

View 7 Replies View Related

Individual SqlDataSource() Or Common SqlDataSource() ?

Mar 8, 2007

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

View 1 Replies View Related

Asp:sqldatasource - Sum And Contains

Aug 20, 2006

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

View 1 Replies View Related

SqlDataSource

Oct 11, 2006

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?

View 2 Replies View Related

SqlDatasource

Dec 18, 2006

Hi all

View 2 Replies View Related

Sqldatasource

Jan 15, 2007

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

View 2 Replies View Related

Using SQLDataSource

Feb 23, 2007

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 

View 2 Replies View Related

SQLDataSource

Mar 30, 2007

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!

View 4 Replies View Related

SqlDataSource

Apr 12, 2007

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")
 
SqlDataSource1.DataBind()
objReader.objconnection.Close()
 
End If
End Sub
Thanks.
 
 

View 1 Replies View Related

How To Get A Value From SQLDataSource

May 28, 2007

Hi!Please tell me, how to get a simple value using SQLDataSource, I mean a number, or char, or string - any value, NOT DataTable 

View 3 Replies View Related

EOF With SqlDataSource

Jul 23, 2007

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]"
 
thanks,

View 1 Replies View Related

Something About Sqldatasource

Aug 13, 2007

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.... 

View 2 Replies View Related

Using An SQLDataSource For Than Once

Aug 21, 2007

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
  
 

View 3 Replies View Related

Sqldatasource

Oct 28, 2007

please explain selectparameter collection and conflict detection property and filterparameter
mohsen

View 1 Replies View Related

What Is SqlDataSource

Oct 29, 2007

Hi, I want to know when to use an sqlDataSource object because I used to populate for example a listBox control in visual studio net 2003 from AQLK server database by using a connection object, command object, dataAdapter object and a DataSet object. I discovered if I use sqlDataSource object (using visual studio net 2005) ,all I need is to write the connection string and a Select statement as properties for that sqlDataSource, so why to use the above mentioned objects(connection,command,adapter,dataset) while I can access any database in sql server through the use of sqlDataSource?
I appreciate if you can explain to me the difference and when to use an sqlDataSource
thx

View 1 Replies View Related

SqlDataSource

Dec 4, 2007

How can I update more than one table with one UpdateString in SqlDataSource?

View 5 Replies View Related

Do You Really Use SqlDataSource?

Dec 9, 2007

Hi,
I have an application w/ n-tier design so I've never used the SqlDataSource up to this point but having to do my own sorting for GridViews is not something I want to keep dealing with. I'd like to take advantage of some of the packaged features too.
My question is: are there any purists out there who opted to use SqlDataSource. If so, what do you think about it? It's nice that SqlDataSource makes things simple but having data classes and dealing w/ exceptions in those classes certainly make an application pretty robust. Should I entertain the idea of using SqlDataSource or stay as a purist and keep doing things the old fashioned way?

View 1 Replies View Related

Sqldatasource?

Dec 30, 2007

How to display returned data from sqldatasurce in a textbox.
This code is not working TextBox1.Text = SqlDataSource2.ToString(); Thanks Lot.

View 2 Replies View Related

SqlDataSource

Jan 16, 2008

Hey all,I've just started to use asp.net and so far have found it fairly easy. The only problem I've come across is with putting variable clauses into the SqlDataSources.This is one example of what I've done trying to get this to work. <asp:SqlDataSource ID="ClaimsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT TOP 20 dbo_ClaimStatus.ClaimStatus, dbo_CLAIMS.PACKET, dbo_INSURED.NAME, dbo_FEES.INSURER, dbo_FEES.CLAIM_NUMBER, dbo_CLAIMS.LOSS_DATE, dbo_CLAIMS.RECEIVED, dbo_CLAIMS.LOSS_LOCATION, dbo_CLAIM_TYPES.CODE FROM ( ( ( ( dbo_CLAIMS INNER JOIN dbo_CLAIM_TYPES ON dbo_CLAIMS.CLAIM_TYPE = dbo_CLAIM_TYPES.CODE ) INNER JOIN dbo_ClaimStatus ON dbo_CLAIMS.StatusID = dbo_ClaimStatus.ClaimStatusID ) INNER JOIN dbo_FEES ON dbo_CLAIMS.PACKET = dbo_FEES.PACKET ) INNER JOIN dbo_INSURED ON dbo_CLAIMS.PACKET = dbo_INSURED.PACKET ) WHERE dbo_ClaimStatus.ClaimStatus = @claimStatus"> <FilterParameters> <asp:QueryStringParameter Name="claimStatus" QueryStringField="ctl00$MainContent$claimStatus" /> </FilterParameters></asp:SqlDataSource>I'm posting claimStatus from a previous page using PostBackUrl on an <asp:Button /> tag and claimStatus is an <asp:DropDownList /> tag.Any idea's as to why this doesn't work?Nalum 

View 2 Replies View Related

SqlDataSource

Feb 24, 2008

Dear Friends in my project , i' ve used two SqlDataSource, one button and one gridview control;
the process that i want to do is when i click the button control ,according the  if structure in this button control ; one of the SqlDataSource control assign to the gridview control DataSource property (but i assign the DataSourceID property for the gridview , it runs);
but i couldnt do it, what can i do for it? (my code  doesnt give any errors but doesnt do anything too)
my code is here;
protected void btnSearch_Click(object sender, EventArgs e)     {         if (txtSearch.Text != null){             SqlDataSource3.SelectParameter["key"].DefaultValue = txtsearch.Text;             Gridview1.DataSource = SqlDataSource3;             GridView1.DataBind();         }         else         {             SqlDataSource1.SelectParameters["keySession"].DefaultValue = cbSession.SelectedItem.ToString();             SqlDataSource1.SelectParameters["keyClass"].DefaultValue = cbClass.SelectedItem.ToString();             SqlDataSource1.SelectParameters["keyUnit"].DefaultValue = cbUnit.SelectedItem.ToString();             Gridview2.DataSource = SqlDataSource1;             GridView2.DataBind();         }
 

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved