Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have added a dataset and connected with my table (Add New Item >> DataSet) Then I am trying to use the following code to fill Tableadapter with my dataset. But it is showing an error. Could anybody help me please?
VB
Dim dAdt As New SqlDataAdapter()
    dAdt.Fill(dsArticles, "tblArticles")

Please also note I have put a parameter on my dataset as well (where ProductID=@PID) Thanks
Posted
Comments
Varun Sareen 23-Feb-12 5:25am    
what error? Please post
Furqan Sehgal 23-Feb-12 5:27am    
It says on dsArticles "dsArticles is a type and can not be used as an expression"
Varun Sareen 23-Feb-12 5:35am    
Please post some more code.
Herman<T>.Instance 23-Feb-12 5:32am    
please show more code, command, connection and declaration of dsArticles
Furqan Sehgal 23-Feb-12 7:34am    
I have not declared dsArticles, I just created it by adding New Item

this link will prove to be of much help for your question:-

http://msdn.microsoft.com/en-us/library/bh8kx08z.aspx[^]

Don't forget to mark this as your answer if it helps you out.

Thanks
 
Share this answer
 
Please add connection and SQL query in Data Adapter like

Dim dAdt As New SqlDataAdapter("select * from table",con)
dAdt.Fill(dsArticles, "tblArticles")

con = your connection to database
("select * from table" = please insert your query
 
Share this answer
 
v2
Comments
Furqan Sehgal 24-Feb-12 9:53am    
I really do not want to do this........ I want to write as little code as possible. Found something on http://rhondatipton.net/2006/07/03/typed-datasets-in-c/
going to test.........
Add dataset using Add New >> Dataset and configure it.
Then in the namespace of the forms, add reference as
Imports DemoApplication.dsArticlesTableAdapters

Demoapplication is the name of your application and dsArticles is the name of added DataSet.

Then in the button, where you want to access the dataset and table, add code:
VB
' Access Table Adapter
       Dim ta As New tblArticlesTableAdapter()
       ' Access Dataset
       Dim dt As dsArticles.tblArticlesDataTable = ta.GetData(txtArtNo.Text)
       MsgBox(dt.Rows.Count)
 
Share this answer
 

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