Hello,

I'm kind of new to this but have successfully launched a database UI before but this time I am using the Datagridview to display by data. I do this by OLEDB and establish my connection (see code below) and bind too two different datagrids:

Public Sub FindTroubleshootingTable()
Dim SS As String
Dim EC As String
Dim tablename As String
Dim instrumentname As String
Dim i As Integer

i = SearchGrid.CurrentRow.Index
SS = SearchGrid.Item(0, i).Value
EC = SearchGrid.Item(1, i).Value

If ToolStripLabel.Text = "Phadia 250" Then
instrumentname = "P250"
tablename = "P250-" & SS & "_" & EC & ""
Else
instrumentname = "P1000"
tablename = "P1000-" & SS & "_" & EC & ""
End If


m_Connection.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Diagnostic Tool\FSE Database.mdb"

m_Connection.Open()

m_DataAdapter = New OleDb.OleDbDataAdapter("Select * From " & instrumentname & "", m_Connection)
TSDA = New OleDb.OleDbDataAdapter("Select * From [" & tablename & "]", m_Connection)

m_CommandBuilder = New OleDb.OleDbCommandBuilder(m_DataAdapter)
TSCB = New OleDb.OleDbCommandBuilder(TSDA)

m_PhadiaDataSet = New DataSet()
TSDS = New DataSet()

m_DataAdapter.Fill(m_PhadiaDataSet, instrumentname)
TSDA.Fill(TSDS, tablename)

m_PhadiaDataView = New DataView(m_PhadiaDataSet.Tables(instrumentname))
TSDV = New DataView(TSDS.Tables(tablename))

m_CurrencyManager = CType(Me.BindingContext(m_PhadiaDataView), CurrencyManager)
'TSCM = StepGrid.BindingContext(TSDV)

m_Connection.Close()


SearchGrid.DataSource = m_PhadiaDataView
StepGrid.DataSource = TSDV
SearchGrid.Columns.Remove("ID")

Now I am trying to update my datatable from datagridview "StepGrid" and I get a OleDbException was unhandled "No value given for one or more required parameters.

Here is my code for the update processes

Private Sub btnAdd_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim SS As String
Dim EC As String
Dim tablename As String
Dim i As Integer
Dim instrumentname As String

i = SearchGrid.CurrentRow.Index
SS = SearchGrid.Item(0, i).Value
EC = SearchGrid.Item(1, i).Value

If ToolStripLabel.Text = "Phadia 250" Then
instrumentname = "P250"
tablename = "P250-" & SS & "_" & EC & ""
Else
instrumentname = "P1000"
tablename = "P1000-" & SS & "_" & EC & ""
End If


Dim n As Object
n = StepGrid.CurrentRow.Index

If TSDS.Tables(tablename).Rows.Count <> 0 Then
TSDS.Tables(tablename).Rows(n)("ID") = StepGrid.Item(0, n).Value.ToString
TSDS.Tables(tablename).Rows(n)("Step1") = StepGrid.Item(1, n).Value.ToString
TSDA.Update(TSDS, tablename)
StepGrid.Refresh()

ElseIf TSDS.Tables(tablename).Rows.Count = 0 Then
Dim NR As DataRow = TSDS.Tables(tablename).NewRow()

NR(0) = StepGrid.Item(0, n).Value
NR(1) = StepGrid.Item(1, n).Value
TSDS.Tables(tablename).Rows.Add(NR)
TSDS.Tables(tablename).Rows(n)("ID") = StepGrid.Item(0, n).Value
TSDS.Tables(tablename).Rows(n)("Step1") = StepGrid.Item(1, n).Value
TSDA.Update(TSDS, tablename)

End If

MsgBox("Records Updated")

End Sub

I'll keep working on it but it's got me stuck at the moment. I bind my datagridview by the dataview in case you are wondering

On your TSDA data adapter you have only defined the SELECT command.
You need to define also the commands for INSERT, UPDATE and DELETE before calling TSDA.Update

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.