EDN Admin
Well-known member
i am workin with sql server and vb 10. when i run the program, i encounter the following error - Conversion failed when converting date and/or time from character string
this my code
<pre class="prettyprint lang-vb Private Sub updateinvoiceDB()
If InvoicedetailsDataGridView.Rows.Count > 0 Then
Dim invoiceID As Integer = CInt(InvoiceTableAdapter.GetLastIdentityValue)
Dim datedb As Date = DateDateTimePicker.Value
myconnection = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|kankukhDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
myconnection.Open()
sql = "INSERT INTO invoice (date, name, address, total, tax1, tax2) VALUES (" & datedb & "," & NameTextBox.Text & "," & AddressTextBox.Text & "," & productTotal & "," & tax1 & "," & tax2 & ")"
adapter.InsertCommand = New SqlCommand(sql, myconnection)
adapter.InsertCommand.ExecuteNonQuery()
myconnection.Close()
End If
End Sub[/code]
<br/>
please do help me <hr class="sig shehzi
View the full article
this my code
<pre class="prettyprint lang-vb Private Sub updateinvoiceDB()
If InvoicedetailsDataGridView.Rows.Count > 0 Then
Dim invoiceID As Integer = CInt(InvoiceTableAdapter.GetLastIdentityValue)
Dim datedb As Date = DateDateTimePicker.Value
myconnection = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|kankukhDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
myconnection.Open()
sql = "INSERT INTO invoice (date, name, address, total, tax1, tax2) VALUES (" & datedb & "," & NameTextBox.Text & "," & AddressTextBox.Text & "," & productTotal & "," & tax1 & "," & tax2 & ")"
adapter.InsertCommand = New SqlCommand(sql, myconnection)
adapter.InsertCommand.ExecuteNonQuery()
myconnection.Close()
End If
End Sub[/code]
<br/>
please do help me <hr class="sig shehzi
View the full article