Hi I am new to VB 2010. I have the following code which saves the data from 4 text boxes. The last one is a date field (txtdate) in the database and it gives me error on it. Can you please let me know what is the syntax to specify a date value? I tried with and without quotes. But didn't work.
Code:Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim cn As New OleDb.OleDbConnection cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Test\db1.mdb;Persist Security Info=True" cn.Open() Dim Command As OleDb.OleDbCommand Command = New OleDb.OleDbCommand("INSERT INTO Projects1(ProjectID, ProjectName, ProjectDesc, ProjectDate)" & _ " VALUES (" & txtid.Text & ",'" & txtname.Text & "', '" & txtdesc.Text & "', '" & txtdate.Text & "')", cn) Command.ExecuteNonQuery() cn.Close() MsgBox("New Records Added to the database") End Sub


Reply With Quote
