navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Please Help, this cant be that hard!

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Please Help, this cant be that hard!
Page: [1]
 
51

 

Posts: 49
Joined: 5/30/2002
From:
Status: offline

 
Please Help, this cant be that hard! - 8/6/2003 13:59:34   
Can someone please look at this little bit of code here and please tell me why It will not allow me to update a table and give me this little error on my web browswer.
Here is the error: INSERT INTO people (first,last,dogsname) VALUES (' none' ,' none' ,' ' )The following errors occurred:

yeah, I know no error, but that still is not supposed to be on the screen and yet my table is not updated.

Here is the code:
<html>
<head>
<title>Add Record</title>
</head>
<body>
<h2>Add Record to a Database Table</h2>

<%
on error resume next
set conn=Server.CreateObject(" ADODB.Connection" )
conn.provider=" Microsoft.Jet.OLEDB.4.0"
conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ))

first=Request.Form(" first" )
last=Request.Form(" last" )
dogs_name=Request.Form(" dogsname" )


sql=" INSERT INTO people (first,last,dogsname) VALUES "
sql=sql & " (' " & first & " ' ,' " & last & " ' ,' " & dogsname & " ' )"

Response.Write(sql)


Set result = onlinedb1.Execute (sql)


If onlinedb1.Errors.Count > 0 then
Response.Write (" The following errors occurred:<br>" )
For each Error in onlinedb1.Errors
Response.Write (" Error #: " & Error.Number & " <br>" )
Response.Write (" Error Description: " & Error.Description & " <br>" )
Next
Else
Response.Write (" Record insertion was successful!" )

End If

conn.close
%>


</body>
</html>


Thank you all for your time and any opinion would help.
rdouglass

 

Posts: 9187
From: Biddeford, ME USA
Status: offline

 
RE: Please Help, this cant be that hard! - 8/6/2003 14:10:59   
Do you allow zero-lenght fields in your DB?

Just a quick guess. If not, you' ll need default values for all fields you' re trying to INSERT....

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to 51)
51

 

Posts: 49
Joined: 5/30/2002
From:
Status: offline

 
RE: Please Help, this cant be that hard! - 8/6/2003 14:45:56   
I am not too familiar with " zero lenth" fields. I am rather new at this. sorry for the confusion.

(in reply to 51)
rdouglass

 

Posts: 9187
From: Biddeford, ME USA
Status: offline

 
RE: Please Help, this cant be that hard! - 8/6/2003 14:55:12   
It looks like you' re using an Access DB. You need to open the DB (in Access) and check the field definitions:


Thumbnail Image
:)

Attachment (1)

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to 51)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Please Help, this cant be that hard! - 8/6/2003 15:33:10   
Also, you are inserting " dogsname" when the variable is " dogs_name"

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to 51)
rdouglass

 

Posts: 9187
From: Biddeford, ME USA
Status: offline

 
RE: Please Help, this cant be that hard! - 8/6/2003 15:36:42   
quote:

Also, you are inserting " dogsname" when the variable is " dogs_name"


Oh yeah........:):):)

Good thing Spooky' s around to keep me in check! :)

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to 51)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Please Help, this cant be that hard! - 8/6/2003 15:40:08   
Shouldnt effect the error if its null though ;-)

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to 51)
51

 

Posts: 49
Joined: 5/30/2002
From:
Status: offline

 
RE: Please Help, this cant be that hard! - 8/7/2003 13:02:52   
I set the property to Allow Zero Length to " YES" but I still get the same error, I believe the sql string is correct, the query will work, but there isnt a query being made. i think it has something to do with the line conn.execute(sql)....

Add.asp code:

<html>
<head>
<title>Add DataBase Record</title>
</head>
<body>

<%
set conn=Server.CreateObject(" ADODB.Connection" )
conn.Provider=" Microsoft.Jet.OLEDB.4.0"
conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ))
set rs = Server.CreateObject(" ADODB.Recordset" )
rs.Open " select * from people" , conn
%>

<h2>Adding a Record</h2>
<form method=" post" action=" new.asp" target=" _blank" >
<table bgcolor=" #b0c4de" >
<%
for each x in rs.Fields
if x.name <> " no" then%>
<tr>
<td><%=x.name%></td>
<td><input name=" <%=x.name%>" value=" none" size=" 20" ></td>
<%
end if
next
rs.close
conn.close
%>
</tr></table>
<br />
<input type=" submit" name=" action" value=" Add Record" >
</form>
</body>
</html>


then the new.asp code:

<html>
<head>
<title>Add Record</title>
</head>
<body>
<h2>Add Record to a Database Table</h2>

<%
on error resume next
set conn=Server.CreateObject(" ADODB.Connection" )
conn.provider=" Microsoft.Jet.OLEDB.4.0"
conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ))

first=Request.Form(" first" )
last=Request.Form(" last" )
dogsname=Request.Form(" dogsname" )

' Define table to query and SQL statement START '

sql=" INSERT INTO people (first,last,dogsname) VALUES "
sql=sql & " (' " & first & " ' ,' " & last & " ' ,' " & dogsname & " ' )"

' Define table to query and SQL statement END '

' write the sql to be executed '
Response.Write(sql)

conn.execute(sql)
' Set result = conn.Execute(sql)
conn.close
%>

</body>
</html>

do you know why it isnt sending the query?
maybe i should take that " onerror moveNext" out? and maybe it will show me something?

(in reply to 51)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Please Help, this cant be that hard! - 8/7/2003 14:44:46   
Yep, remove the on error to see what the true error is?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to 51)
rdouglass

 

Posts: 9187
From: Biddeford, ME USA
Status: offline

 
RE: Please Help, this cant be that hard! - 8/7/2003 14:56:07   
quote:

<%
on error resume next
set conn=Server.CreateObject(" ADODB.Connection" )
conn.provider=" Microsoft.Jet.OLEDB.4.0"
conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ))

first=Request.Form(" first" )
last=Request.Form(" last" )
dogsname=Request.Form(" dogsname" )
.......


I have 2 questions about this section:

1. If you hardcode first, last, and dogsname; does it now work?

2. If you combine these 2 lines:

conn.provider=" Microsoft.Jet.OLEDB.4.0"
conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ))

to make 1 line:

conn.open(" Microsoft.Jet.OLEDB.4.0;Data Source =" & server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ))

does that have any effect? When you do those two things, what SQL response.writes?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to 51)
51

 

Posts: 49
Joined: 5/30/2002
From:
Status: offline

 
RE: Please Help, this cant be that hard! - 8/7/2003 15:29:12   
here is the error when I take out the " on error" line

Add Record to a Database Table
INSERT INTO people (first,last,dogsname) VALUES (' test' ,' none' ,' none' )
Microsoft JET Database Engine error ' 80040e14'

Syntax error in INSERT INTO statement.

/ALD/testasp/puntin/new.asp, line 28

(in reply to 51)
51

 

Posts: 49
Joined: 5/30/2002
From:
Status: offline

 
RE: Please Help, this cant be that hard! - 8/7/2003 15:36:02   
When I combine these 2 lines:

conn.provider=" Microsoft.Jet.OLEDB.4.0"
conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ))

to make 1 line:

conn.open(" Microsoft.Jet.OLEDB.4.0;Data Source =" & server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ))


This Error occured:
Add Record to a Database Table
Microsoft OLE DB Provider for ODBC Drivers error ' 80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/ALD/testasp/puntin/new.asp, line 11

(in reply to 51)
rdouglass

 

Posts: 9187
From: Biddeford, ME USA
Status: offline

 
RE: Please Help, this cant be that hard! - 8/7/2003 15:54:16   
quote:

INSERT INTO people (first,last,dogsname) VALUES (' test' ,' none' ,' none' )


I personally see nothing at all wrong with that SQL. Have you double checked all your field names, table names, etc. and made sure they' re all text fields? (Don' t want to insult your intelligence, but I miss things like that myself..) That' s about the only thing at this point I can see...:)

I also am still suspicious of your DB connection - It just doesn' t look right to me...:)

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to 51)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Please Help, this cant be that hard! - 8/7/2003 16:08:49   
51,

Try:

set conn=Server.CreateObject(" ADODB.Connection" )
conn.Open " DBQ=" & Server.Mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ) & " ;Driver={Microsoft Access Driver (*.mdb)};"

_____________________________


(in reply to 51)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Please Help, this cant be that hard! - 8/7/2003 16:10:42   
51,

In your very first post you said UPDATE. But your using INSERT. Insert does not UPDATE, it ADDS a new record. Just so I understand - do you want to UPDATE a record or ADD a new one?

_____________________________


(in reply to 51)
51

 

Posts: 49
Joined: 5/30/2002
From:
Status: offline

 
RE: Please Help, this cant be that hard! - 8/7/2003 16:22:28   
It would ADD, Sorry for the confusion, and I am still getting the error:
Add Record to a Database Table
INSERT INTO people (first,last,dogsname) VALUES (' test' ,' test' ,' test' )
Microsoft OLE DB Provider for ODBC Drivers error ' 80004005'

[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

/ALD/testasp/puntin/new.asp, line 27

here is line 27
conn.execute(sql)

im so lost..... :(

(in reply to 51)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Please Help, this cant be that hard! - 8/7/2003 17:25:04   
51,

Set conn = Server.CreateObject(" ADODB.Connection" )
sql = " INSERT INTO people (first,last,dogsname) VALUES (' test' ,' none' ,' none' )"
conn.Open " Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ) & " ;"
conn.execute(sql)
conn.Close


I noticed your not putting your db in the /fpdb directory.
Are all your permissions set correctly for your /ALD/TESTASP/puntin directory?

Have you performed any other types of tests to detemrine a good connection between your site and it' s database? :)

LLLuneeeee:)

< Message edited by Long Island Lune -- 8/7/2003 5:27:46 PM >


_____________________________


(in reply to 51)
51

 

Posts: 49
Joined: 5/30/2002
From:
Status: offline

 
RE: Please Help, this cant be that hard! - 8/8/2003 7:18:20   
Yes, I know that the connection works as expected. Just can not insert new records for some reason, I know its something simple.

(in reply to 51)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Please Help, this cant be that hard! - 8/8/2003 11:43:29   
Reading and writing are two different things. Just like connections and permissions. Have you tested deleting a record?

As you already know there are 3 types of permissions:

Read
Read / Write
Read / Write / Delete


Normally READ is automatic and does not have to be set. Because one directory may be read/write, that does not mean all of them are. They have to be individually set. Plus your using quite a tree: /ALD/TESTASP/puntin/

If I were you the first thing I would do is make sure the permissions are correct.
Your code should work.

:)

_____________________________


(in reply to 51)
51

 

Posts: 49
Joined: 5/30/2002
From:
Status: offline

 
RE: Please Help, this cant be that hard! - 8/13/2003 14:45:50   
I feel so dumb, yes it was a permission issue, thank you guys for all you help.

(in reply to 51)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Please Help, this cant be that hard! - 8/13/2003 16:20:12   
Congrat's

_____________________________


(in reply to 51)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Please Help, this cant be that hard!
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts