I keep having this error within a line of my code and I can’t seem to fix it.
Here is my code:
con.Open()
Dim dt As DataTable
Dim ds As DataSet
ds.Tables.Add(dt)
Dim da As OleDbDataAdapter
da = New OleDbDataAdapter("Select From * product info", con)
da.Fill(dt)
Dim newRow As DataRow = dt.NewRow
With newRow
.Item("Product Name:") = txtItemName.Text
.Item("Description") = txtDescription.Text
.Item("Quantity:") = txtItemCount.Text
.Item("Type:") = cmbItemType.Text
.Item("Date Received:") = txtDate.Text
.Item("Barcode:") = txtBarcode.Text
.Item("Price:") = txtPrice.Text
End With
dt.Rows.Add(newRow)
Dim cb As OleDbCommandBuilder(da)
da.Update(dt)
con.Close()
In the Dim cb As OleDbCommandBuilder(da) line I get the error on the da
You have mixed the initialization and declaration of the variable cb.
The correct syntax to use is
or
or (as explained by Konrad below)