Question SQL Statement

johnnyjohnson

New member
Joined
Sep 5, 2008
Messages
1
Programming Experience
Beginner
Hi,
Please could someone tell me whats wrong with this line of code:
VB.NET:
Expand Collapse Copy
SQL = "INSERT INTO times (Computer Name, Date Time, Button) VALUES ('" & n & "', '" & dt & "', '" & b & "')"

n, dt and b are string variables. I am getting a sysntax error but its not telling me exactly whats wrong.

Thanks
 
Inertia's got a point, but otherwise than that, what's the Exception? or does it even compile? Lots or stuff can go wrong, but the most obvious thing I can think of is that you have some fields that are not initialized by your insert. Or maybe you pass string that contain single quotes and that messes up the SQL...

It is much easier to work with SQL through a typed dataset. It hides the complexity of building the actual query behind a single generated method...
 
Back
Top