Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to this.........cannot create a connection..... 2

Status
Not open for further replies.

Yogi39

Technical User
Jun 20, 2001
273
CA
Trying to create an asp connetion to a access data base in front page ...to which I will eventualy pass values from a form to...however been trying in vain to set up a basic connection......and I cannot even see the page in my browser...can someone please point out the obvious.....as this is my first week of programming asp and web applications...Thanks......


<%
Set db = Server.CreateObject(&quot;ADODB.Connection&quot;)
db.Open &quot;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=&quot; & Server.MapPath(&quot;login_name.mdb&quot;) & &quot;;UID=;PWD=&quot;
db.execute(&quot;INSERT INTO Results VALUES ('Jon Doe', 22)&quot;)
set rs=db.execute(&quot;SELECT * FROM Results&quot;)

rs.MoveFirst
Do Until rs.EOF
Response.Write rs(&quot;ogin&quot;) & &quot;<br>&quot;
rs.MoveNext
Loop

db.execute(&quot;DELETE FROM Results WHERE ogin = 'Jon Doe'&quot;)



%>
 
Microsoft JET Database Engine error '80004005'

Number of query values and destination fields are not the same.
 
Your error is stemming from your SQL command, not your connection statement.

You have not supplied all the values for the table -- i.e. there are more columns in your table than the two that you have specified values for...

Try doing something like this:

INSERT INTO tableName (colName1, colName2) VALUES (val1, val2)

and see if that helps any....

:)
Paul Prewett
penny.gif
penny.gif
 
Tried this for a quick test......

Set db = Server.CreateObject(&quot;ADODB.Connection&quot;)
db.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;fpdb/login_name.mdb&quot;) & &quot;;&quot;

db.execute(&quot;INSERT INTO Results (cologin, colass) VALUES (val1, val2)<BR>&quot;)
set rs=db.execute(&quot;SELECT * FROM Results&quot;)
rs.MoveFirst
Do Until rs.EOF
Response.Write rs(&quot;ogin&quot;) & &quot;<br>&quot;
rs.MoveNext
Loop

db.execute(&quot;DELETE FROM Results WHERE NAME = 'val1'&quot;)
%>

Got following Error using Netscape to test....

Microsoft JET Database Engine error '80040e14'

Missing semicolon (;) at end of SQL statement.

/johnny/Test.asp, line 6
 
db.execute(&quot;INSERT INTO Results (cologin, colass) VALUES (val1, val2)<BR>&quot;)

Why is that <br> in there???? Take that out and add the semicolon that it's asking for.
penny.gif
penny.gif
 
Just so you know the Query Strings, is not HTML, so dont confuse HTML with your SQL Query. Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
Thanks for the help...actualy making progress(U gusee)

<%
Set db = Server.CreateObject(&quot;ADODB.Connection&quot;)
db.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;fpdb/login_name.mdb&quot;) & &quot;;&quot;

strFullName = Request.Form(&quot;ogin&quot;)
strName = Request.Form(&quot;ass&quot;)
strPassword = Request.Form(&quot;ail&quot;)


db.execute(&quot;INSERT INTO Results(ogin, ass, ail)&quot; & _
&quot; VALUES ('&quot; & strFullName & &quot;','&quot; & strName & &quot;', '&quot; & strPassword & &quot;')&quot;)



%>

<form method=&quot;POST&quot; action=&quot;Test.asp&quot;>


now getting...
Microsoft JET Database Engine error '80004005'

Field 'Results.ogin' cannot be a zero-length string.

/johnny/Test.asp, line 11
 
Thanks for the patience and help.......FINALY got the syntax errors out and it is working..
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top