-
Nov 25th, 2015, 05:28 AM
#1
Thread Starter
Lively Member
[RESOLVED] Datatable incorrectly loading from datasource.
Can anyone please tell me what im missing here. This code is supposed to make a dataset "ds", make three data tables (GOODS_RECEIPTS, GOODS_RECEIPTS_DG and STOCK_ADJUSTMENT_TABLE ). Then load the values of the select commands into the relevant data tables.
But instead I end up with the results of the
"daGOODS_RECEIPTS.UpdateCommand = New FbCommand("SELECT FIRST 1 * FROM GOODS_RECEIPTS WHERE RECORDSTATE = 1", connection)"
command in both GOODS_RECEIPTS and GOODS_RECEIPTS_DG tables.
Visual basic 2010.
connection.Open() 'Open connection
'create a new FB dataadapter daGOODS_RECEIPTS
Dim daGOODS_RECEIPTS As FbDataAdapter = New FbDataAdapter("SELECT FIRST 1 * FROM GOODS_RECEIPTS WHERE RECORDSTATE = 1", connection)
Dim fbCmdBuilder = New FbCommandBuilder(daGOODS_RECEIPTS) 'activate command builder
'create a new dataset
Dim ds As New DataSet("GOODS_RECEIPTS_DATASET") 'Create dataset ds
Dim GOODS_RECEIPTS As DataTable = ds.Tables("GOODS_RECEIPTS")
Dim GOODS_RECEIPTS_DG As DataTable = ds.Tables("GOODS_RECEIPTS_DG")
Dim STOCK_ADJUSTMENT_TABLE As DataTable = ds.Tables("STOCK_ADJUSTMENT_TABLE")
Try 'Fill data set but if a queiry returns nothing and we try to fill a datatable with nothing an error occurers
'fill the dataset/table with GOODS RECEIPTS data
daGOODS_RECEIPTS.UpdateCommand = New FbCommand("SELECT FIRST 1 * FROM GOODS_RECEIPTS WHERE RECORDSTATE = 1", connection)
daGOODS_RECEIPTS.FillSchema(ds, SchemaType.Source, "GOODS_RECEIPTS")
daGOODS_RECEIPTS.Fill(ds, "GOODS_RECEIPTS")
daGOODS_RECEIPTS.Update(ds, "GOODS_RECEIPTS")
'fill the dataset/table with GOODS RECEIPTS DG data
daGOODS_RECEIPTS.UpdateCommand = New FbCommand("SELECT * FROM GOODS_RECEIPTS_DG WHERE GOODSRECEIPTSNUMBER = " & ds.Tables("GOODS_RECEIPTS").Rows(0).Item("SEQ") & "", connection)
daGOODS_RECEIPTS.FillSchema(ds, SchemaType.Source, "GOODS_RECEIPTS_DG")
daGOODS_RECEIPTS.Fill(ds, "GOODS_RECEIPTS_DG")
daGOODS_RECEIPTS.Update(ds, "GOODS_RECEIPTS_DG")
DataGridView1.DataSource = ds.Tables("GOODS_RECEIPTS")
DataGridView2.DataSource = ds.Tables("GOODS_RECEIPTS_DG")
DataGridView1.Refresh()
DataGridView2.Refresh()
'fill the dataset/table with STOCK ADJUSTMENT TABLE data
daGOODS_RECEIPTS = New FbDataAdapter("SELECT * FROM STOCK_ADJUSTMENT_TABLE ", connection)
daGOODS_RECEIPTS.FillSchema(ds, SchemaType.Source, "STOCK_ADJUSTMENT_TABLE")
daGOODS_RECEIPTS.Fill(ds, "STOCK_ADJUSTMENT_TABLE")
daGOODS_RECEIPTS.Update(ds, "STOCK_ADJUSTMENT_TABLE")
Catch
Timer1.Enabled = False
connection.Close()
Return
End Try
Thank you.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|