I am new to dot net. I want to addd a record inside the table using oledb. Can somebody give me code. How to add record. code which I am trying is following - Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\arch.mdb") Dim objcommand As OleDb.OleDbCommand = New OleDb.OleDbCommand() Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click objcommand.Connection = conn objcommand.CommandText = "insert into my(name,age,dept)VALUES (@name,@age,@dept);" objcommand.Parameters.Add("@name", TextBox1.Text) objcommand.Parameters.Add("@age", TextBox2.Text) objcommand.Parameters.Add("@dept", TextBox1.Text)
You shouldn't create your SQL statements directly from user input. Create variables and clean them for SQL injection first.