i'm developing software for Production Planning i which i find some problems :
1. My datagridview contains data from different text boxes , textboxes are getting data from different tables (eg with help forms in my application ) . Now i want to save this filled grid in database. for which i tried this :
Private Sub btnSave_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnSave.Click
Dim NoRows As Integer
With GridProdDet
NoRows = .RowCount
For i = 1 To NoRows - 1
If AddFlg = True Then
Call InsertRecords(.Item(0, i).Value, .Item(1, i).Value, .Item(2, i).Value, .Item(3, i).Value, .Item(4, i).Value, .Item(5, i).Value, .Item(6, i).Value, .Item(7, i).Value, .Item(8, i).Value, .Item(9, i).Value, .Item(13, i).Value, .Item(14, i).Value)
End If
Next
End With
End Sub
Private Sub InsertRecords(ByVal Mach As Integer, ByVal head As String, ByVal Part As String, ByVal desc1 As String, ByVal modelNm As String, ByVal mdCd As Integer, ByVal ShftNo As Integer, ByVal ShftType As String, ByVal TimeFr As Integer, ByVal TimeTo As Integer, ByVal sec As Integer, ByVal scrp As Integer)
Dim str As OleDbConnection
Dim cmdSaveProdTube As OleDbCommand
str = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\TubeProd\production.mdb;")
str.Open()
cmdSaveProdTube = New OleDbCommand
Try
With cmdSaveProdTube
.Connection = str
.CommandText = "Insert into tblinfo (mach_no,main_hd, part_no,desc,m_name,model_cd,shift_no,shift_type,t ime_fr,time_to,sec_qty,scrp_qty)" & _
"Values('" & Mach & "', '" & head & "', '" & Part & "', '" & desc1 & "', '" & modelNm & "','" & mdCd & "','" & ShftNo & "','" & ShftType & "','" & TimeFr & "','" & TimeTo & "', '" & sec & "','" & scrp & "' )"
.ExecuteNonQuery()
End With
MsgBox("Sucessfully Save!", MsgBoxStyle.Information, "")
Catch ex As Exception
MsgBox("Error Saving Records", vbExclamation, "")
End Try
End Sub
This is program is not saving data in database.