'this is my code plz guys help how to save data from vb 2005 and other this that i am able to view the data from acess but i am not able save to acess i dont whether my code for save is correct of not ( iam using vb2005 as front end and MS acess as by back end)
Public Class Form1
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
'TODO: This line of code loads data into the 'Database1_beDa taSet.Table1' table. You can move, or remove it, as needed.
Me.Table1TableA dapter.Fill(Me. Database1_beDat aSet.Table1)
End Sub
Private Sub cmdnew_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles cmdnew.Click
Me.Table1Bindin gSource.AddNew( )
End Sub
Private Sub cmdfirst_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdfirst.Click
Me.Table1Bindin gSource.MoveFir st()
If (Val(TextBox1.T ext) = 1) Then
MsgBox("This first record")
End If
End Sub
Private Sub cmdprevious_Cli ck(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdprevious.Cli ck
Me.Table1Bindin gSource.MovePre vious()
If (Val(TextBox1.T ext) = 1) Then
MsgBox("This first record")
End If
End Sub
Private Sub cmdlast_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdlast.Click
Me.Table1Bindin gSource.MoveLas t()
End Sub
Private Sub cmdnext_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdnext.Click
Me.Table1Bindin gSource.MoveNex t()
End Sub
Private Sub cmdsave_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdsave.Click
Dim consql3 As OleDb.OleDbConn ection = _
New OleDb.OleDbConn ection("Provide r=Microsoft.Jet .OLEDB.4.0;Data Source=|DataDir ectory|\Databas e1_be.mdb;")
'Caminho da base de dados
consql3.Open() 'abre a conexao com o banco
'query de busca
Dim sql3 As String = "INSERT INTO Table1(name, class, dept, physis, chemistry, maths) VALUES('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "')"
Dim comam3 As OleDb.OleDbComm and
comam3 = New OleDb.OleDbComm and(sql3, consql3)
Dim adapter As OleDb.OleDbData Adapter = New OleDb.OleDbData Adapter(comam3)
comam3 = New OleDb.OleDbComm and(sql3, consql3)
consql3.Close()
End Sub
Private Sub cmdclear_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdclear.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
'TODO: This line of code loads data into the 'Database1_beDa taSet.Table1' table. You can move, or remove it, as needed.
Me.Table1TableA dapter.Fill(Me. Database1_beDat aSet.Table1)
End Sub
Private Sub cmdnew_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles cmdnew.Click
Me.Table1Bindin gSource.AddNew( )
End Sub
Private Sub cmdfirst_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdfirst.Click
Me.Table1Bindin gSource.MoveFir st()
If (Val(TextBox1.T ext) = 1) Then
MsgBox("This first record")
End If
End Sub
Private Sub cmdprevious_Cli ck(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdprevious.Cli ck
Me.Table1Bindin gSource.MovePre vious()
If (Val(TextBox1.T ext) = 1) Then
MsgBox("This first record")
End If
End Sub
Private Sub cmdlast_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdlast.Click
Me.Table1Bindin gSource.MoveLas t()
End Sub
Private Sub cmdnext_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdnext.Click
Me.Table1Bindin gSource.MoveNex t()
End Sub
Private Sub cmdsave_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdsave.Click
Dim consql3 As OleDb.OleDbConn ection = _
New OleDb.OleDbConn ection("Provide r=Microsoft.Jet .OLEDB.4.0;Data Source=|DataDir ectory|\Databas e1_be.mdb;")
'Caminho da base de dados
consql3.Open() 'abre a conexao com o banco
'query de busca
Dim sql3 As String = "INSERT INTO Table1(name, class, dept, physis, chemistry, maths) VALUES('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "')"
Dim comam3 As OleDb.OleDbComm and
comam3 = New OleDb.OleDbComm and(sql3, consql3)
Dim adapter As OleDb.OleDbData Adapter = New OleDb.OleDbData Adapter(comam3)
comam3 = New OleDb.OleDbComm and(sql3, consql3)
consql3.Close()
End Sub
Private Sub cmdclear_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles cmdclear.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
End Sub
End Class
Comment