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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem opening table 1

Status
Not open for further replies.

Inspin

Technical User
Dec 17, 2002
6
US
Hi this is my first asp project, heres all my code, Its giving me this error:
Code:
"Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
/asp/confirm.asp, line 19
"

here is the related code:
Code:
<%@ Language = &quot;VBScript&quot;%>
<%
'local variables
dim conn
dim rs
dim strID
dim strconn
'Create the Connection object 
set conn = server.createobject(&quot;adodb.connection&quot;)
conn.open &quot;GG&quot;
'Create the recordset object
set rs = server.createobject(&quot;adodb.recordset&quot;)
'open table
rs.open &quot;Main&quot;, conn,2,2

if you need more of the code let me know

thanks,
Ins
 
well, you need one more aspect of that connection
a SQL SELECT statement saying what table and fields you want to populate the recordset with
so
try this out
sqltxt = &quot;SELECT * FROM Main&quot;
' * selects all columns from table
'open table
rs.open sqltxt, conn,2,2
---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

 
You can't say: conn.open &quot;GG&quot;

Look here for some help.....
-----------------------------------------------------------------
&quot;C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.&quot;
- Bjarne Stroustrup

mikewolf@tst-us.com
 
is that the DSN name &quot;GG&quot;?
or are you trying a DSN-Less connection?



Mike [thumbsup2] for the reference. makes me think it isn't that bad of a tutorial. ---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

 
thanks mwolf00,

I corrected that certain error based on information from that site..now i have i think what is my last error:

Code:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Field 'Main.Icode' cannot be a zero-length string.
/asp/confirm.asp, line 61

this is confusing me because Main.Icode is a field in my table. That is a zero length field until it is updated correct? On the HTML form Icode is a checkbox in the table it is a textfield (i was getting a type mismatch error if the Icode in the table was a checkbox as well) here is all my code:

Code:
<%@ Language = &quot;VBScript&quot;%>
<%
'local variables

dim conn
dim dbpath
dim rs
dim strID
dim strconn

'Create the Connection object 
set conn = server.createobject(&quot;adodb.connection&quot;)
Dbpath =&quot;DBQ=&quot; & server.mappath(&quot;\asp\database97\GG.mdb&quot;)
Conn.open &quot;DRIVER={Microsoft Access Driver (*.mdb)}; &quot; & dbpath
'Create the recordset object
set rs = server.createobject(&quot;adodb.recordset&quot;)
'open table
rs.open &quot;Main&quot;, conn,2,2

'Use the addnew method of the recordset object to add a record
rs.addnew
'Set the table column = to my input text box from my form
rs(&quot;prospectname&quot;) = request(&quot;prospect&quot;)
rs(&quot;Icode&quot;) = request(&quot;Iacode&quot;)
rs(&quot;aage&quot;) = request(&quot;aage40&quot;)
rs(&quot;carriers&quot;) = request(&quot;carrier&quot;)
rs(&quot;90percent&quot;) = request(&quot;target&quot;)
rs(&quot;75percent&quot;) = request(&quot;employercost&quot;)
rs(&quot;copay15&quot;) = request(&quot;copay&quot;)
rs(&quot;prefbroker&quot;) = request(&quot;prefbroker&quot;)
rs(&quot;noretiree&quot;) = request(&quot;retiree&quot;)
rs(&quot;cobra&quot;) = request(&quot;cobra7&quot;)
rs(&quot;prospectname&quot;) = request(&quot;pname&quot;)
rs(&quot;city&quot;) = request(&quot;citygg&quot;)
rs(&quot;state&quot;) = request(&quot;stategg&quot;)
rs(&quot;salesrep&quot;) = request(&quot;srep&quot;)
rs(&quot;effdate&quot;) = request(&quot;edate&quot;)
rs(&quot;daterequest&quot;) = request(&quot;drequest&quot;)
rs(&quot;manualrate&quot;) = request(&quot;mrate&quot;)
rs(&quot;industrycode&quot;) = request(&quot;indcode&quot;)
rs(&quot;industryfactor&quot;) = request(&quot;ifactor&quot;)
rs(&quot;averageage&quot;) = request(&quot;aveage&quot;)
rs(&quot;currentcarrier&quot;) = request(&quot;ccarrier&quot;)
rs(&quot;lives&quot;) = request(&quot;numlives&quot;)
rs(&quot;broker&quot;) = request(&quot;bname&quot;)
rs(&quot;brokerfirm&quot;) = request(&quot;bfirm&quot;)
rs(&quot;dhmed&quot;)= request(&quot;chkmed&quot;)
rs(&quot;dhden&quot;)= request(&quot;chkden&quot;)
rs(&quot;mrreduction&quot;)= request(&quot;mrmed&quot;)
rs(&quot;mrreduction_dent&quot;)= request(&quot;mrden&quot;)
rs(&quot;rateadj&quot;)= request(&quot;manmed&quot;)
rs(&quot;rateadj_dent&quot;)= request(&quot;manden&quot;)
rs(&quot;totaladj&quot;)= request(&quot;adjmed&quot;)
rs(&quot;totaladj_dent&quot;)= request(&quot;adjden&quot;)
rs(&quot;soldeffdate&quot;)= request(&quot;soldmed&quot;)
rs(&quot;soldeffdate_dent&quot;)= request(&quot;soldden&quot;)
rs.update
'I do a movelast here to get the ID that is automatically generated 
'I also set the value to a local variable so I can write out to the database
rs.movelast
strID = rs(&quot;ID&quot;)
%>

<html>
<head>
<title>Input Summary</title>
</head>
<body>
<TABLE BORDER=1> 
Your confirmation ID: <b><% = strID %> <br></b>
The Prospect Name you added: <b> <% = request(&quot;prospect&quot;) %> </b>
</body></html>
<%
'clearing the server memory
set rs= nothing
set conn = nothing
%>
</BODY>
</HTML>

thanks for the help so far
 
What your error is telling you is that you are attempting to set it to a zero length with this line...

rs(&quot;Icode&quot;) = request(&quot;Iacode&quot;)


Make sure that you have a value in request(&quot;Iacode&quot;)

Also, &quot;that site&quot; refers to a site written by onpnt - you should probably give him the star for writing it! -----------------------------------------------------------------
&quot;C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.&quot;
- Bjarne Stroustrup

mikewolf@tst-us.com
 
woops.. ;)

I figured out what it is..its the checkboxes..

I have an HTML form with checkboxes and textboxes..the textboxes pass their values to the table completly fine. However the checkboxes pass no value at all even if they are checked to the table. Any idea how I can get the checkboxes to pass any kind of value? or am I better off using combo boxes with &quot;yes or no&quot; choices?

Ins
 
I believe that checkboxes pass a value like &quot;on&quot; when they are checked. What you should do on this page is to do something like:

IF request(&quot;Iacode&quot;) = &quot;on&quot; then iCode = &quot;true&quot; else iCode = &quot;false&quot;
-----------------------------------------------------------------
&quot;C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.&quot;
- Bjarne Stroustrup

mikewolf@tst-us.com
 
stupid question but do you ahve a value for the checkbox in the tag.
for instance if you have
<FORM method=&quot;get&quot;>
dogs
<input type=&quot;checkbox&quot; name=&quot;item1&quot; value=&quot;dogs&quot;>
cats
<input type=&quot;checkbox&quot; name=&quot;item2&quot; value=&quot;cats&quot;>

and submit the form you will recieve in th URL
?item1=dogs&item2=cats&Submit=Submit
with both checked

and with no checkboxes checked
?Submit=Submit

so to validate a value
if Request.QueryString(&quot;dogs&quot;) <> &quot;&quot;
hence you must have passed a value so further the occurance of the processing of that checkbox ---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

 
alright thanks guys, i got it =)

and onpnt the checkboxes (whether they were checked or not) were processing, they were just trying to pass zero length strings to my table.


thanks again for the time ;)



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top