debauch
01-28-2008, 09:16 AM
I am trying to send data to an Access database, can anyone see this issue below??
Inherits System.Windows.Forms.Form
'The System.Data.OleDb.OleDbConnection class represents a connection to OleDb data source
Dim cn As OleDbConnection
'The System.Data.OleDb.OleDbCommand class represents a SQL statement or stored procedure
'that is executed in a database by an OLE DB provider.
Dim cmd As OleDbCommand
Dim icount As Integer
Dim str, EmpID As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
EmpID = txtEmpID.Text 'empId
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\track.mdb;User ID=Admin;")
cn.Open()
str = "insert into tblTrack ([EmpID]) values ('" & EmpID & "')"
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery()
MessageBox.Show("Congratulations")
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
cn.Close()
End Sub
Inherits System.Windows.Forms.Form
'The System.Data.OleDb.OleDbConnection class represents a connection to OleDb data source
Dim cn As OleDbConnection
'The System.Data.OleDb.OleDbCommand class represents a SQL statement or stored procedure
'that is executed in a database by an OLE DB provider.
Dim cmd As OleDbCommand
Dim icount As Integer
Dim str, EmpID As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
EmpID = txtEmpID.Text 'empId
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\track.mdb;User ID=Admin;")
cn.Open()
str = "insert into tblTrack ([EmpID]) values ('" & EmpID & "')"
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery()
MessageBox.Show("Congratulations")
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
cn.Close()
End Sub