Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql insert not working

Status
Not open for further replies.

hsingh1981

Programmer
Apr 8, 2008
56
GB
Hi all i get an error msg in my vb.net 2003. can anyone see problem with my sql statement?

Code:
        sql = "INSERT INTO T_AnnualLeave (StaffID, LeaveStart, LeaveEnd, Notes, LeaveDays) "
        sql = sql + "VALUES('" & staffid & "',#" & startdate & "#, #" & enddate & "# , '" & notes & "', '" & days & "')"
regards

farouq
 
I see lots of problems.

1. You haven't told us what the error message says
2. The # key around dates isn't needed in SQL Server
3. SQL Injection


[!]
-------------------------------------------------------

Mark,

Join me at the new IT Community of the 21st Century: [!][URL unfurl="true"]http://lessthandot.com[/!][/url]

[/!]
 
Hi thanks for replying....i finally sussed it out. You're absolutely right regarding # is not needed in sql server.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top