im working in SQL Server environment for the remote server and locally in vb.net, a DataTable()
Yes, you should be able to edit the tags. And you should add tags for dotnet, to get help from those people, since if I understand this correctly this is a .NET problem. I'm an SQL guy, but I will try to share with what I know.
To fill the DataSet
, you use DataAdapter.Fill
. I don't seem to have a sample in Visual Basic around, but here is an example in PowerShell:
$cn = New-Object SqlConnection $connstr;
$cn.Open();
$cmd = New-Object SqlCommand(
"SELECT TOP 1000 * FROM dbo.Customers", $cn);
$cmd.CommandType = [CommandType]::Text;
$da = New-Object SqlDataAdapter($cmd);
$dt = New-Object DataTable;
$nrows = $da.Fill($dt);
The flow is the same in Visual Basic. Only the syntax is different. Here I'm filling a DataTable
, but you can also use a DataSet
.
To write back the data, the best is to use a table-valued parameter, and in this case I actually have an article that discusses this in detail, Using Table-Valued Parameters in SQL Server and .NET.. Short summary, you can pass the DataTable
directly to the TVP. (Most of the article discusses other means that are better for the cases when you don't already have a DataTable
, so you only need to read the first couple of pages.)