Will anyone show me how to insert data into a mdb file? Heres what I have and it doesnt work.
Any suggestion is greatly appreciated!
ljCharlie
Private Shared mdbPath As String = Application.StartupPath & "\Computers.mdb"
Public Shared Sub dataInsert(ByVal txtPserial As TextBox, ByVal txtCpName As TextBox, ByVal txtVersion As TextBox, ByVal txtTime As TextBox, ByVal txtDate As TextBox, ByVal txtWhat As TextBox, ByVal txtAddtnInfo As RichTextBox)
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & mdbPath
Dim strPserial, strName, strVersion, strTime, strDate, strWhat, strAddtnInfo As String
Dim cn As New OleDbConnection(strConn)
cn.Open()
Dim cmd As OleDbCommand = cn.CreateCommand()
strPserial = txtPserial.Text
strName = txtCpName.Text
strVersion = txtVersion.Text
strTime = txtTime.Text
strDate = txtDate.Text
strWhat = txtWhat.Text
strAddtnInfo = txtAddtnInfo.Text
cmd.CommandText = "INSERT INTO Program (PSerial, Name, Version, Time, Date, What, Addtn_Info) VALUES (" & strVersion & ", " & strName & ", " & strVersion & ", " & strTime & ", " & strDate & ", " & strWhat & ", " & strAddtnInfo & ")"
Dim intRecordAffected As Integer = cmd.ExecuteNonQuery()
If intRecordAffected = 1 Then
MsgBox("Insert Successful")
End If
End Sub
Any suggestion is greatly appreciated!
ljCharlie