Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, I want to insert the date into my table , but error appears when i tried to run.

 

Here is the code:

 

Private Sub CmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSave.Click

       mycommand.Dispose()
           mycommand.Connection = cn
       mycommand.CommandText = "INSERT INTO ReminderTable(Subject,Date,Message) VALUES(@Subject,@Date,@Message) "
           mycommand.Parameters.Add("@Subject", TextBox1.Text)
       mycommand.Parameters.Add("@Date", CDate(TextBox4.Text))
           mycommand.Parameters.Add("@Message", TextBox3.Text)
           Try
               cn.Open()
               If cn.State = ConnectionState.Open Then
                   MessageBox.Show("Connection Opened Successfully")
                   mycommand.ExecuteNonQuery()
               End If
           Catch frans As System.Exception
           MessageBox.Show(frans.ToString)
               Me.Dispose()
           End Try


           cn.Close()

   End Sub

Is there anything wrong with the code?

It went wrong when i try to add the date (textbox4.text), but if i dont use the date and just insert the subject and message, it can run successfully.

The problem is on the date which i dont know why.

when i try to catch the error message, the message is:

SYNTAX ERROR IN INSERT INTO STATEMENT

 

Please help me...

 

Thanks in advance

Posted

hi, i've been trying all day to try and try,but it still didnt work.

 

Can you help me post a very very simple way to insert date format into the access table or the date format to convert the date from the textbox ?

 

thank you very much for your help

Posted

after a long day looking for the correct way, suddenly IT WORKS....

 

I changed the textbox with DateTimePicker

and the value with DateTimePicker1.Value

 

I have tried this before, but didnt work, but now it works.... :)

but still I'm curious why it didnt work for the textbox.

 

any comments will be much appreciated and thank you for your help :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...