baz86
asked on
"Data conversion failed. [ OLE DB status value (if known) = 2 ]"
Hi All,
I get this error when i run the query below. (with the pointer at cmd.ExecuteNonQuery).
Im not sure what data conversion its trying to do as im using simple data types...
can someone give me any pointers/advice as what to change or what the problem is.
I get this error when i run the query below. (with the pointer at cmd.ExecuteNonQuery).
Im not sure what data conversion its trying to do as im using simple data types...
can someone give me any pointers/advice as what to change or what the problem is.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New SqlCeConnection("Data Source=\My Documents\ECADDY.sdf")
conn.Open()
Dim sql As String = "INSERT tblPlayer (FirstName,PlayerNo) VALUES ('Joe','1')"
Dim cmd As New SqlCeCommand(sql, conn)
cmd.ExecuteNonQuery() ' Execute the command here
'and then read
Dim myreader As SqlCeDataReader
myreader = cmd.ExecuteReader
conn.Close()
End Sub
End Class
ASKER
Thanks for the reply. I still get the same SqlCeException was unhandled: Data Conversion failed error message with the change.
Try
"INSERT INTO tblPlayer (FirstName,PlayerNo) VALUES ('Joe',1)"
"INSERT INTO tblPlayer (FirstName,PlayerNo) VALUES ('Joe',1)"
ASKER
Thanks jpaulio. that seemed to work! (in that there were no errors) but none of the values seemed to be added to the table. would you know why that would be?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i made the addition to the code above....but still when i preview the data for the form..there seems to be nothing in there...the code runs fine but doesnt seem to place the values into the table
To be sure you have to check direcly on the table.
How do you preview the data for the form ? With this ?
Dim myreader As SqlCeDataReader
myreader = cmd.ExecuteReader
How do you preview the data for the form ? With this ?
Dim myreader As SqlCeDataReader
myreader = cmd.ExecuteReader
ASKER
not sure if this was the right way to check but on Data Sources, right click then Preview Data?
i also binded the table onto another form to show its contents but shows nothing
i also binded the table onto another form to show its contents but shows nothing
ASKER
[ive just increased the points for this question]
Double click on the ECADDY.sdf to open the server explorer and look in the right table (tblPlayer)
ASKER
jpaulino thanks for all your help on this. The query now works and it adds to the database.
when i originally checked server explorer and the table as you stated above, all the columns were NULL but when i checked the query analyzer on the PDA it showed the entries.
when i originally checked server explorer and the table as you stated above, all the columns were NULL but when i checked the query analyzer on the PDA it showed the entries.
Ok, glad I could help!
"INSERT INTO tblPlayer (FirstName,PlayerNo) VALUES ('Joe','1')"