|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
That's why it's ALWAYS good practice to Response.Write your SQL Queries *******B E F O R E********** you execute them...
For example, get into the habit of doing this: <% . . . . . . SQL_DetailsRetreival = "SELECT IPaddress FROM tblIP WHERE IPaddress ='" & grabIP & "'" SQL_InsertData = "insert into tblIP (IPaddess) values (" & grabIP & ")" 'FOR DEBUG ONLY Response.Write SQL_DetailsRetreival & "<hr>" Response.End SET objRst = objConnect.execute(SQL_DetailsRetreival) . . . . . . %> Then COPY/PASTE the query result from your browser into your database, run it see if it works! Then comment the two lines under the 'FOR DEBUG ONLY section Now your INSERT query should look like this: SQL_InsertData = "insert into tblIP (IPaddess) values ('" & grabIP & "')" Hope this helps! Sincerely Vlince |
|
#17
|
|||
|
|||
|
Thanks Vlince, the code works perfectly and I can now see how the syntax works.
However on the subject of syntax, how would you go about inserting more than one peice of data in to more than one table column? For example I have 3 strings: sessionID, URLName, URLAddress How could I insert these 3 pieces of data in the same table in different columns so that one row contains these 3 peices of information? here is the SQL that obviously only inserts one peice of info: SQL_InsertData = "insert into tblURL (urlName) values ('" & URLName & "')" many thanks. |
|
#18
|
|||
|
|||
|
Look at the documentation of an INSERT query
Here... INSERT [INTO] table_or_view [(column_list)] data_values Example INSERT INTO MyTable (PriKey, Description) VALUES (123, 'A description of part 123.') Hope this helps! Sincerely Vlince |
|
#19
|
||||
|
||||
|
Separate the column and value names with commas.
Code:
SQL_InsertData = "INSERT INTO tblURL (column1, column2, column3) values (value1, value2, value3) Check out www.w3schools.com/sql for some easy lessons on basic sql syntax. edit: darn, too slow. ![]()
__________________
--Dave-- U2kgSG9jIExlZ2VyZSBTY2lzLCBOaW1pdW0gRXJ1ZGl0aW9uaXMgSGFiZXM= |
|
#20
|
|||
|
|||
|
LOL
Well your example shows an INSERT query with 3 fields which is what the poster wanted, I only gave him 2 fields...making him work a little ;-) |
|
#21
|
|||
|
|||
|
Hahaha, yeah ive sure been working hard tonight!!!!!!!!!!
Well thanks to you guys I have a MUCH better understanding of using databases with ASP and ive finished! It all works! So thanks a million and see you soon! |
|
#22
|
|||
|
|||
|
Where's our money?
Did you really think that our advice was free ??? Are you serious? Anyway, a little donation to karsh44 & Vlince inc. foundation would be appreciated AND EXPECTED. period. Hope this helps! Sincerely Vlince |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > How to use SQL to add a record? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|