I have a field set as Datetime and i have a variable that gets todays date... when i try to insert the date i get this error..
System.Data.OleDb.OleDbException: Syntax error converting datetime from character string.
Here is my code
VB Code:
Imports System.Data.OleDb Public Class WebForm2 Inherits System.Web.UI.Page Dim Conn As OleDbConnection, Command As OleDbCommand, DataRead As OleDbDataReader Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Title As String, Teaser As String, Full As String, TheDate As String Title = Request.Form("txtTitle") Teaser = Request.Form("txtTeaser") Full = Request.Form("txtFull") TheDate = CDate(Date.Today.ToString)'Todays date i.e... 6/20/2003 ExecuteQuery("INSERT INTO tblNews (NewsTitle,NewsTeaser,NewsFull,NewsDate) VALUES ('Title','Teaser','Full','TheDate')", "Test") Conn.Close() End Sub Public Sub ExecuteQuery(ByVal SQL As String, ByVal DB As String) If Application("Connection") Is Nothing Then Try Conn = New OleDbConnection(System.Configuration.ConfigurationSettings.AppSettings.Get(DB)) Conn.Open() Command = New OleDbCommand(SQL, Conn) DataRead = Command.ExecuteReader(CommandBehavior.CloseConnection) Catch ex As Exception Response.Write(ex) End Try Else Response.Write("Couldn't execute Query, Already Connected. Close the connection and try again.") End If End Sub End Class
I dont domprendeh why it's saying it cant convert the date
![]()
Thanks!![]()





Reply With Quote