Link to home
Start Free TrialLog in
Avatar of zipzip
zipzip

asked on

Error help : Microsoft VBScript runtime error '800a01a8' , Object required: ''

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/test/signup.asp, line 98


<% if Request.form("Submit") <> "" then

dim conn,rs,sql
conn = Server.CreateObject("ADODB.Connection")
rs = Server.CreateObject("ADODB.Recordset")
sql= "INSERT INTO tab (firstname,lastname,username,password) VALUES " &_
 "('" & Request("txtfirstname") & "'),('" & Request("txtlastname") &_
 "'),('" & Request("txtusername") &  "'),('" & Request("txtpassword") & "')"

conn.Provider = "Microsoft.Jet.OLEDB.4.0"            
conn.ConnectionString = "Data Source= " & server.MapPath("db1.mdb")
conn.open

set rs = conn1.Execute(sql1)

if (rs.eof) and (rs.bof) then
Response.Redirect("default.asp")
else
Response.write("Register fail. Please, Register again")
end if

rs.close
set rs=nothing
conn.close
set conn=nothing

end if
%>
Avatar of sciber_dude
sciber_dude
Flag of United States of America image

>> conn = Server.CreateObject("ADODB.Connection")

>> set rs = conn1.Execute(sql1)

Guess u need to change conn1 to conn on the lower line.
:) SD
and Sql1 to sql.
:) SD
Also, if you include <%Option Explicit%> at the top of your pages it will help you find these type of errors in the future...

Option Explicit means that you have to Dim all your variable, and it would have errored on conn1 and SQL1 because they are not dimmed...at least not in the code you gave.
Avatar of zipzip
zipzip

ASKER

<% if Request.form("Submit") <> "" then

dim conn,rs,sql
conn = Server.CreateObject("ADODB.Connection")
rs = Server.CreateObject("ADODB.Recordset")
sql= "INSERT INTO tab (firstname,lastname,username,password) VALUES " &_
 "('" & Request("txtfirstname") & "'),('" & Request("txtlastname") &_
 "'),('" & Request("txtusername") &  "'),('" & Request("txtpassword") & "')"

conn.Provider = "Microsoft.Jet.OLEDB.4.0"            
conn.ConnectionString = "Data Source= " & server.MapPath("db1.mdb")
conn.open

set rs = conn.Execute(sql)

if (rs.eof) and (rs.bof) then
Response.Redirect("default.asp")
else
Response.write("Register fail. Please, Register again")
end if

rs.close
set rs=nothing
conn.close
set conn=nothing

end if
%>

========
Microsoft VBScript runtime error '800a01a8'

Object required: ''

/test/signup.asp, line 99
which line is it pointing to @ line 99 ?

SD
oops! hold on!

What are u trying to do here? Why do u need an rs if u are inserting into the database?

Try this code. This inserts the values into the database and if there is no error, then it goes to default.asp. else it will write "Register fail. Please, Register again"

<% if Request.form("Submit") <> "" then

dim conn,rs,sql
conn = Server.CreateObject("ADODB.Connection")
sql= "INSERT INTO tab (firstname,lastname,username,password) VALUES " &_
 "('" & Request("txtfirstname") & "','" & Request("txtlastname") &_
 "','" & Request("txtusername") &  "','" & Request("txtpassword") & "')"

conn.Provider = "Microsoft.Jet.OLEDB.4.0"            
conn.ConnectionString = "Data Source= " & server.MapPath("db1.mdb")
conn.open

conn.Execute(sql)

if err <> 0 then
      Response.Redirect("default.asp")
else
      Response.write("Register fail. Please, Register again")
end if

conn.close
set conn=nothing

end if
%>

Avatar of zipzip

ASKER

same error
object require : "
Avatar of zipzip

ASKER

is rs.AddNew and sql = "insert into " statement  do the same thing?

which method of create/insert record is best?

>> object require : "

Can you tell me which line this error is on.

For eg. if the line number is 99, go to your code view and go to (Ctrl+G in Frontpage) line 99 and copy that line and paste it here.

This will help in localizing the error.

> which method of create/insert record is best?
alorentz, this would be ur domain :P u are the expert.

:) SD
Avatar of zipzip

ASKER

line 99 :

conn.Provider = "Microsoft.Jet.OLEDB.4.0"        

============
and this is the code above line 98:

<% if Request.form("Submit") <> "" then

dim conn,rs,sql
conn = Server.CreateObject("ADODB.Connection")
rs = Server.CreateObject("ADODB.Recordset")
sql= "INSERT INTO tab (firstname,lastname,username,password) VALUES " &_
 "('" & Request.Form("txtfirstname") & "'),('" & Request.Form("txtlastname") &_
 "'),('" & Request.Form("txtusername") &  "'),('" & Request.Form("txtpassword") & "')"
I suspect your database path may not be correct. Try this code, if it is incorrect, it should give you an error "The connection isnt open yet!"

<% if Request.form("Submit") <> "" then

dim conn,rs,sql

strDataPath = server.MapPath("db1.mdb")

strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & " Data Source= " & strDataPath & ";"_
               & " Mode=Share Deny None;User Id=admin;PASSWORD=;"

if not IsObject("conn") then
     set conn=Server.CreateObject("ADODB.Connection")
     conn.ConnectionTimeout = 15
     conn.CommandTimeout =  10
     conn.Mode = 3 'adModeReadWrite
     if conn.state = 0 then
          conn.Open strConnectString
     end if
end if

if conn.state = 0 then
      response.write "The connection isnt open yet!"
      response.end
end if

sql= "INSERT INTO tab (firstname,lastname,username,password) VALUES " &_
 "('" & Request("txtfirstname") & "','" & Request("txtlastname") &_
 "','" & Request("txtusername") &  "','" & Request("txtpassword") & "')"

conn.Execute(sql)

if err <> 0 then
      Response.Redirect("default.asp")
else
      Response.write("Register fail. Please, Register again")
end if

conn.close
set conn=nothing

end if
%>


Avatar of zipzip

ASKER

Variable is undefined: 'strDataPath'

/test/signup.asp, line 94


nice to get ur feedback so soon. can I have your email or messanger id so that we can chat?
Avatar of zipzip

ASKER

after variable declaration,

Syntax error in INSERT INTO statement
> nice to get ur feedback so soon. can I have your email or messanger id so that we can chat?
I think that the rules of EE say that we cant do this

good, we are getting somewhere @ Syntax error in INSERT Statement,

Add this line BEFORE "conn.Execute(sql)"

reponse.write sql            ' displays the sql statement so that you can troubleshoot the error.
response.end                  ' stop executing after this point

conn.Execute(sql)

Once you do this, post what you see on the screen.

:) SD
typo! arghhh!!

Add this line BEFORE "conn.Execute(sql)"

response.write sql            ' displays the sql statement so that you can troubleshoot the error.
response.end                   ' stop executing after this point

conn.Execute(sql)

Once you do this, post what you see on the screen.
Avatar of zipzip

ASKER

INSERT INTO tab (firstname,lastname,username,password) VALUES ('a','a','a','a')
okay..

copy this query and paste it in a query in the MS access database and try to run it.

Most probably these could be the reasons.

1. The table tab is not present
2. One or more fields firstname,lastname,username,password are not present
3. One or more fields firstname,lastname,username,password is/are not text fields.

Trying to run the access query will tell u where the problem is.

Once u know the problem, fix it in the database and/or ASP code. Dont forget to remove/comment-out the response.end statement to test ur code again.

:) SD
Avatar of zipzip

ASKER

the sql statement no problem...data can be inserted,

but in asp, the code return error

SQL INSERT INTO error
ASKER CERTIFIED SOLUTION
Avatar of sciber_dude
sciber_dude
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zipzip

ASKER

I changed my code to AddNew method and it works just fine.

so, I just want to know what is the [] stands for above? then I will give u pts :D
Avatar of zipzip

ASKER

after putting [], error still occur..

Avatar of zipzip

ASKER

thanks SD, nice teaching :)

I think the problem is the method I use in query - 'insert into' not allow because of permission (maybe you could explain to me how to assign permission)

so after I change method to SELECT FROM and insert data using rs.fields(), it works perfectly.
> 'insert into' not allow because of permission (maybe you could explain to me how to assign permission)

To enable permissions for insert and update, you need to have access to the database on the server. If your database is on a remote server, then you will have to ask a network administrator to do it. If it is on a local drive then go to the directory which has the database in the Windows explorer and right click on the database to see the properties.

When the database properties dialog box opens up, click on the [Security] tab.

Make sure you have the following users (or you add them) IUSR_{ServerName} and IWAM_{ServerName} users and also make sure they have full control over the database.

:) SD

PS: {ServerName} is the name of the server ... for eg. if the servername is SERVER22 then the user is IUSR_SERVER22