hi,
im trying out a simple code in which i add data to my database.....
but its giving me error saying Syntax error in INSERT INTO statementCode:Dim dr As DataRow strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\rs232\rem.mdb;User Id=;Password=;" Dim cmd As New OleDbCommand("INSERT INTO reminderdata (datetime, reminder)VALUES('" & txtdate.Text & "','" & txtreminder.Text & "')", New OleDbConnection(strconn)) cmd.Connection.Open() cmd.ExecuteNonQuery() cmd.Connection.Close()
so i tried the code given here
and declared the insert command asCode:dr = ds.Tables(0).NewRow() 'Gets a reference to a new row. dr("datetime") = txtdate.Text dr("reminder") = txtreminder.Text ds.Tables(0).Rows.Add(dr) da.Update(ds) ds.AcceptChanges()
Code:da.InsertCommand = New OleDbCommand("INSERT INTO reminderdata(datetime, reminder) VALUES(@datetime,@reminder)") da.InsertCommand.Connection = conn da.InsertCommand.Parameters.Add("@datetime", OleDbType.VarChar, 40, "datetime") da.InsertCommand.Parameters.Add("@reminder", OleDbType.VarChar, 40, "reminder")
but i got the same error.....![]()
plz help me resolve the error.....




Reply With Quote