New to VB.Net,
How to insert or select the dataset value.
cmd = New SqlCommand("Select * from table1", con)
ada = New SqlDataAdapter(cmd)
ds = New DataSet
ada.Fill(ds)
cmd = New SqlCommand("Select * from '" & ds.Tables(0) & "' ", con)
mydatatable1.Load(dr3)
It was showing the error in '" & ds.Tables(0) & "', I want to get the dataset value
Need VB.Net Code Help
You have a reasonable idea right up until you get to the point where you are trying to create a second SqlCommand. That is, once you do the Fill, you already have the data in a table. You wouldn’t run another select – you’ve already done that. You’d just reference the table that you want to use in the dataset.
If you want a data table you would do something like this (for VB, see below):
Now, if you don’t need a DataTable, per se, but just want to read from the query, you’d use a SqlDataReader:
Then just read from the nwReader:
Update: I don’t know VB but here is what I think it would look like:
You may well be able to shorten this to get rid of the extra SqlCommand (assuming VB supports this SqlDataAdapater syntax like C#.
Good luck…