SunQuest
 
           SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old March 17th, 2000, 08:29 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,578 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
Insert into Access Table with SQL

<i><b>Originally posted by : Matt (dvdauthority@aol.com)</b></i><br /><br />I downloaded the Insert records code and it all "appears" to be working. I enter everything and it says "Your records have been updated" however when I got to check my database, the information is not there.<br /><br />Here's some info on my DB. My table and DB name are both "testing". My fields are (no quotes):<br />"column_one"<br />"column_two"<br />"column_three"<br />"column_four"<br />"link"<br />"image"<br /><br />Here's my .html code<br />====================<br /><br /><form method="post" name="form1" action="addrecords.asp"><br /><p><strong>Title</strong><br><br /><br /><input type="text" size="40" name="text1"><br><br /> <br /><strong>Author</strong><br><br /><input type="text" size="40" name="text2"><br><br /><br /><strong>Date added</strong><br><br /><input type="text" size="40" name="text"><br><br /><br /><strong>Type of Review</strong><br><br /><input type="text" size="40" name="text4"><br><br /><br /><strong>Link</strong><br><br /><input type="text" size="40" name="text5"><br><br /><br /><strong>Image location</strong><br><br /><input type="text" size="40" name="text6"><br><br /><br /><p><input type="Submit" value="Submit New Example" name"b1"> </font></p><br /></form><br /><br />Here's my .asp code<br />===================<br /><br /><%@ Language = "VBScript"%><br /><%<br />'Declare all local variables<br />dim conn<br />dim rs<br />'dim strconn<br />dim strsql<br />dim col1<br />dim col2<br />dim col3<br />dim col4<br />dim link<br />dim image<br /><br />strsql = ""<br />'set connection string to local variable-I use a DSN-less connection<br />'strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("testing.mdb")<br /><br />'build the sql statement based on the input from the form<br />strSQL = "INSERT INTO testing(column_one, column_two, column_three, column_four, link, image)"<br />strSQL = strSQL & " SELECT "<br />strSQL = strSQL & "'" & request("col1") & "' as text1," <br />strSQL = strSQL & "'" & request("col2") & "' as text2,"<br />strSQL = strSQL & "'" & request("col3") & "' as text3,"<br />strSQL = strSQL & "'" & request("col4") & "' as text4," <br />strSQL = strSQL & "'" & request("link") & "' as text5,"<br />strSQL = strSQL & "'" & request("image") & "' as text6,"<br /><br /><br />'Set connection object <br />Set con = Server.CreateObject("ADODB.Connection")<br />con.open "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=d:xxx.xx.xxx.xx esting.mdb"<br />'Use the execute method of the connection object the insert the record<br />'conn.execute(strSQL)<br />'conn.close<br />set conn = nothing<br />%><br /><html><head><br /><title>SQL Add record example</title><br /></head><br /><br /><body><br /><% = "Your record has been added" %><br /></body><br /></html><br /><br />if anyone can help figure this out, I'm forever grateful. Thanks so much in advance.<br /><br />-Matt<br /><br />

Reply With Quote
  #2  
Old March 19th, 2000, 12:55 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,578 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
<i><b>Originally posted by : steve schofield</b></i><br />if this is the exact code you use the con.execute line is commented out. you actually have to execute your strsql statement.<br /><br />steve<br /><br /><br />------------<br />Matt at 3/17/2000 6:29:49 PM<br /><br /><br />I downloaded the Insert records code and it all "appears" to be working. I enter everything and it says "Your records have been updated" however when I got to check my database, the information is not there.<br /><br />Here's some info on my DB. My table and DB name are both "testing". My fields are (no quotes):<br />"column_one"<br />"column_two"<br />"column_three"<br />"column_four"<br />"link"<br />"image"<br /><br />Here's my .html code<br />====================<br /><br /><form method="post" name="form1" action="addrecords.asp"><br /><p><strong>Title</strong><br><br /><br /><input type="text" size="40" name="text1"><br><br /> <br /><strong>Author</strong><br><br /><input type="text" size="40" name="text2"><br><br /><br /><strong>Date added</strong><br><br /><input type="text" size="40" name="text"><br><br /><br /><strong>Type of Review</strong><br><br /><input type="text" size="40" name="text4"><br><br /><br /><strong>Link</strong><br><br /><input type="text" size="40" name="text5"><br><br /><br /><strong>Image location</strong><br><br /><input type="text" size="40" name="text6"><br><br /><br /><p><input type="Submit" value="Submit New Example" name"b1"> </font></p><br /></form><br /><br />Here's my .asp code<br />===================<br /><br /><%@ Language = "VBScript"%><br /><%<br />'Declare all local variables<br />dim conn<br />dim rs<br />'dim strconn<br />dim strsql<br />dim col1<br />dim col2<br />dim col3<br />dim col4<br />dim link<br />dim image<br /><br />strsql = ""<br />'set connection string to local variable-I use a DSN-less connection<br />'strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("testing.mdb")<br /><br />'build the sql statement based on the input from the form<br />strSQL = "INSERT INTO testing(column_one, column_two, column_three, column_four, link, image)"<br />strSQL = strSQL & " SELECT "<br />strSQL = strSQL & "'" & request("col1") & "' as text1," <br />strSQL = strSQL & "'" & request("col2") & "' as text2,"<br />strSQL = strSQL & "'" & request("col3") & "' as text3,"<br />strSQL = strSQL & "'" & request("col4") & "' as text4," <br />strSQL = strSQL & "'" & request("link") & "' as text5,"<br />strSQL = strSQL & "'" & request("image") & "' as text6,"<br /><br /><br />'Set connection object <br />Set con = Server.CreateObject("ADODB.Connection")<br />con.open "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=d:xxx.xx.xxx.xx esting.mdb"<br />'Use the execute method of the connection object the insert the record<br />'conn.execute(strSQL)<br />'conn.close<br />set conn = nothing<br />%><br /><html><head><br /><title>SQL Add record example</title><br /></head><br /><br /><body><br /><% = "Your record has been added" %><br /></body><br /></html><br /><br />if anyone can help figure this out, I'm forever grateful. Thanks so much in advance.<br /><br />-Matt<br /><br />

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Insert into Access Table with SQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway