| | |
SQL problem - simple?
![]() |
•
•
Join Date: Apr 2009
Posts: 30
Reputation:
Solved Threads: 0
so im trying 2 add data to my table in the database, done all the connection (OLEDB one)
so this code adds to my database:
this is one column, im trying to add more to the table StaffID
whats wrong with this SQL statement to add all the fields to the database?
so this code adds to my database:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
SQL = "Insert into Bookings(StaffID) values('" & stafid.Text & "')" DC1 = New OleDbCommand(SQL, cN) DC1.ExecuteNonQuery() MsgBox("Record Saved, Thank you!", MsgBoxStyle.OkOnly, "")
this is one column, im trying to add more to the table StaffID
whats wrong with this SQL statement to add all the fields to the database?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
SQL = "Insert into Bookings(StaffID,RoomID,Date required,Time required,Additional requirements) values('" _ & "'" & stafid.Text & "', " _ & "'" & rooid.Text & "', " _ & "'" & date1.Text & "', " _ & "'" & time1.Text & "', " _ & "'" & areq.Text & "')"
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
& "'" & stafid.Text & "', " _ & "'" & rooid.Text & "', " _ & "'" & date1.Text & "', " _ & "'" & time1.Text & "', " _ & "'" & areq.Text & "')"
rename rooid.Text to roomid.Text
also
stafid.Text to staffid.Text
if thats not the correct names
Last edited by Zermoth; May 1st, 2009 at 11:16 am.
Hi,
Field Names which have SpecialCharacters/Spaces, need to be enclosed in a Square Bracket..
Try This :
SQL = "Insert into Bookings(StaffID,RoomID,[Date required]," _
& " [Time required],[Additional requirements]) values('" _
& "'" & stafid.Text & "', " _
& "'" & rooid.Text & "', " _
& " #" & date1.Text & "#, " _
& " #" & time1.Text & "#, " _
& "'" & areq.Text & "')"
Also, Date/Time Fields need to to be wrapped in with #, instead of single quote.
Regards
Veena
Field Names which have SpecialCharacters/Spaces, need to be enclosed in a Square Bracket..
Try This :
SQL = "Insert into Bookings(StaffID,RoomID,[Date required]," _
& " [Time required],[Additional requirements]) values('" _
& "'" & stafid.Text & "', " _
& "'" & rooid.Text & "', " _
& " #" & date1.Text & "#, " _
& " #" & time1.Text & "#, " _
& "'" & areq.Text & "')"
Also, Date/Time Fields need to to be wrapped in with #, instead of single quote.
Regards
Veena
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- my sql problem (PHP)
- Copy records from one table to samme table in another sql server (MS SQL)
- multiple checkboxes adding values to single sql column (PHP)
- Simple Question PLease URGENT (MS SQL)
- Weird ASP/SQL Problem (ASP)
- problem for a simple asp.net query (ASP)
- ASP/SQL - Problem (ASP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Denying Access Database
- Next Thread: need help with VB6
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






