Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 10th, 2005, 10:29 AM   #1
eggsy
Newbie
 
Join Date: Dec 2004
Posts: 5
Rep Power: 0 eggsy is on a distinguished road
Question SQL in Visual Basic??!

Hi all

Can anyone tell me whether the below code is correct? Well I suppose really its a stupid question because it doesn't work so has anybody got any ideas?


Private Sub cmdCreateLoan_Click()
Dim custID As String
custID = txtCustomerNumber.Text

Dim individualItemNo As String
individualItemNo = txtItem.Text

Dim dateOut As Date
dateOut = CurrentDate
Dim dateBack As Date
dateBack = dueDate
datLoans.Recordset.AddNew
datLoans.RecordSource = "INSERT INTO LoanDetails VALUES('&custID', '&individualItemNo', '&dateOut', '2', '&dateBack', '', '')"
datLoans.Refresh
End Sub


Regards and thanks all

James
eggsy is offline   Reply With Quote
Old Mar 10th, 2005, 2:00 PM   #2
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Well for a start that's not how you refer to VB variables in a string - you need "INSERT INTO LoanDetails VALUES('" & custID & "', '" & individualItemNo &"', '" & dateOut & "', '2', '" & dateBack & "', '', '')" assuming you need the ' quotes in the actual SQL. However I don't think you can execute SQL on what you're using in that way - take a look at the VisData sample project that came with VB for more info.
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:41 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC