Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
I have created a datasource to connect with SQL Data Base. It works fine when I connected it with GridView. I need to read certain item (say FirstName) and store the value to a variable.
How can I use this datasource? Could you give me the statements for that?

Thanks
Posted

1 solution

You have got your Datasource by name ds(say),

Now, you can read the particular values as :

VB
Dim FirstName As String = Convert.ToString(ds.Tables("TableEmp").Rows(0).Item("FirstName"))


I hope this solves your query.

Anurag
 
Share this answer
 
v4
Comments
Furqan Sehgal 4-Sep-11 10:22am    
It does not work. MyDataSource. does not display Tables or further commands that you mentioned. Please note I am using vb.net
@nuraGGupta@ 4-Sep-11 10:38am    
ohhh sorry, I posted my answer in C#, please see my updated answer (Although that is not much different).
Furqan Sehgal 4-Sep-11 10:56am    
It says Table is not a member of system.web.ui.webcontrols........
@nuraGGupta@ 4-Sep-11 11:04am    
I guess when you say datasource, you mean dataset. The given link may help you out :

http://www.homeandlearn.co.uk/net/nets12p6.html
Wendelius 4-Sep-11 11:37am    
I believe that the OP means a datasource, not dataset. For example: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.aspx[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900