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:
  #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,575 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: 24
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,575 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: 24
<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





 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

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





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek