This is the error I receive while debugging.
{"Syntax error in string in query expression ''Laptop);'."}
This is the SQL statement I have that isn't working properly. No matter what I do it seems to add a random . at the end of the statement, and I have no idea why it's doing it.
Sql = "INSERT INTO Devices ( [Asset Number], [Service Tag], Manufacturer, ModelName, Location, Room, Cart, [Purchase Date], Department, [Device Type] ) VALUES('" & AssetNum & "','" & ServTag & "','" & Manu & "','" & Model & "','" & Location & "','" & Room & "','" & Cart & "','" & PurchDate & "','" & Department & "','" & DeviceType & ");"
This is a statement that I've made that works just fine. It's just one long string value. The reason I need the variables above to work is because they're linked to textboxes so the user can input the data.
Sql = "INSERT INTO Devices ( [Asset Number], [Service Tag], Manufacturer, ModelName, Location, Room, Cart, [Purchase Date], Department, [Device Type] )VALUES (10, 1234, 'Dell', 'Latitude E6410', 'John McIntire', 100, 0, '5/17/2015', 'Technology', 'Laptop');"
So yeah basically I'm stuck and can't figure out why the first query doesn't work. I've been stuck on it for awhile now and could really use some assistance.
This is how I execute the queries.
cmd = New OleDb.OleDbCommand(Sql)
cmd.Connection = dbConn
cmd.ExecuteNonQuery()
DeviceTypelike this:"','" & DeviceType & "');"Or use a parameter query and don't bother about quoted string values.What is wrong...you are concatenating SQL rather than using Parameters. Extra/missing ticks cant happen (among other more devastating things) with Parameters.