473,498 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sqldatasource access in code behind

1 New Member
I am very familiar with Visual studio 2003 and trying to get a handle on 2005

I can set up the datasource and make it work fine when I databind it to a control like a gridview or details view. Everything is done automatically no programming.

I need to take a sqldatasource that I have already created with parameters etc. Set the parameter in the code behind, run it against the database and get the result.

in 2003 I would creat a command, run it with a datareader as use a while statement to scroll through the results. something like this.
System.Data.SqlClient.SqlDataReader dr;
this.cmdGet.Parameters["@ClientNumber"].Value = System.Int32.Parse(this.txtSearchedClient.Text);

this.cnMainConnection.Open();
dr = this.cmdGet.ExecuteReader();

while(dr.Read())
{ string myresult=dr["Phone"].ToString()}
}

I can't seem to find out how to do this with a sqldatasource. I figured that it would be like a dataadapter where I would go
dataAdapter.Selectcomand.parameters["someparameter"].value but this does not work

can anyone give me a chunk of sample code for me to work with? I can only find samples in inline asp and haven't been able to get it to work.

Thanks
May 15 '07 #1
0 1278

Sign in to post your reply or Sign up for a free account.

Similar topics

5
4459
by: Martin Bischoff | last post by:
Hi, is it possible to modify the values of a SqlDataSource's select parameters in the code behind before the select command is executed? Example: I have an SqlDataSource with a...
15
26885
by: Swetha | last post by:
Hello I have a DropDownList that I am populating using the following SqlDataSource: <asp:DropDownList ID="parentIDDropDownList" runat="server" DataSourceID="SqlDataSource3"...
1
1871
by: staeri | last post by:
Hello! I would like to set the SqlDataSource in the code behind file and not to have it in the aspx file. How can I do that? Regards, Staeri
3
12722
by: Dorte | last post by:
Hi, Could someone help me with a couple of links to SqlDatasource documentation on how to use the Gridview and SqlDatasource components in code behind? Basically I'm missing some documentation...
2
19757
by: phil | last post by:
Hi, I want to put a recordset in a gridview but i don't know how to pass the value of the variable in the 'where' statement. The value of the variable is set in the code-behind. i added a tag...
4
1480
by: saturnius | last post by:
Hello, I have to save the data from a gridview as XML file. The code is shown below. Is there no easier way? I would like to access either asp:SqlDataSource (me.SqlDataSource1.something) or...
4
11388
by: Casper | last post by:
Hi, i know how to use datareader in code-behind, e.g. like this: Dim oConnection As OleDbConnection Dim comd As OleDbCommand Dim dtreader As OleDbDataReader oConnection = New...
3
2902
by: markpringle | last post by:
This is my sqldatasource this is on the page: <asp:sqldatasource runat="server" ID="DS_CheckUserName" ConnectionString="<%$ ConnectionStrings:SQL2005_355184_ConnectionString %>" ...
1
3064
by: Pipo Dyer | last post by:
Hello Everybody, I am Using @@IDENTITY from MS Access (YES-It is possible) using SqlDataSource -NO STORE PROC- in ASP.NET {VB CODE} to retrieve the ID of a inserted record. Please keep in mind I...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.