Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Old 09-25-2007, 07:07 PM edit a database
Extreme Talker

Posts: 176
Trades: 0
Code:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.ConnectionString = "Data Source=" & Server.MapPath ("datab/db1.mdb")
Conn.Open

Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open "SELECT * FROM affil", Conn, 1,3

straffillink = request.form("affillink")
straffilimage = request.form("affilimage")

Rs.addnew
Rs("affillink") = straffillink
Rs("affilimage") = straffilimage
Rs.update

set Rs = nothing
set Conn = nothing
%>
I tried this, but it give an error, and says the database or object it read only, and points at 'Rs.addnew'.

how can i fix this?
Skeddles is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-25-2007, 07:21 PM Re: edit a database
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
well, at first sight, did you checked that the mdb file was not read-only for the server process ?

Or maybe the DB is locked. I don't know if access files implements locks though...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-25-2007, 09:04 PM Re: edit a database
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
You'd be better off with an insert query.

http://www.w3schools.com/sql/sql_insert.asp

You don't need a recordset object to use it. Just create your SQL query and use Conn.Execute (SQL query).
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 09-25-2007, 10:13 PM Re: edit a database
Extreme Talker

Posts: 176
Trades: 0
Quote:
Originally Posted by ADAM Web Design View Post
You'd be better off with an insert query.

http://www.w3schools.com/sql/sql_insert.asp

You don't need a recordset object to use it. Just create your SQL query and use Conn.Execute (SQL query).
Sorry, im kinda new to this.

Code:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.ConnectionString = "Data Source=" & Server.MapPath ("datab/db1.mdb")
Conn.Open

Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open "SELECT * FROM affil", Conn, 1,3

straffillink = request.form("affillink")
straffilimage = request.form("affilimage")

INSERT INTO affil (link, image)
VALUES (straffillink, straffilimage)

set Rs = nothing
set Conn = nothing
%>
Now it tells me 'Expected end of statement' and points to 'affil' after INSERT INTO.
Skeddles is offline
Reply With Quote
View Public Profile
 
Old 09-25-2007, 10:14 PM Re: edit a database
Skilled Talker

Posts: 97
Name: Ganesh
Trades: 0
Skeddles,

There could be couple of issues

1. Like tripy said

2. Make sure the IUSR_Machiname user has proper rights (Computer Management) to work with the .mdb file. This is internet guest user which is used by the IIS server to execute CGI.
__________________
Gather. Search. Compare. Save on Hotel and Flight Prices @
Please login or register to view this content. Registration is FREE
sri_gan is offline
Reply With Quote
View Public Profile
 
Old 09-25-2007, 10:17 PM Re: edit a database
Skilled Talker

Posts: 97
Name: Ganesh
Trades: 0
Quote:
Originally Posted by Skeddles View Post
Sorry, im kinda new to this.

Code:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.ConnectionString = "Data Source=" & Server.MapPath ("datab/db1.mdb")
Conn.Open
 
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open "SELECT * FROM affil", Conn, 1,3
 
straffillink = request.form("affillink")
straffilimage = request.form("affilimage")
 
INSERT INTO affil (link, image)
VALUES (straffillink, straffilimage)
 
set Rs = nothing
set Conn = nothing
%>
Now it tells me 'Expected end of statement' and points to 'affil' after INSERT INTO.

Skeddles,

Here is the fixed code.



Code:
<%
 
dim sql

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.ConnectionString = "Data Source=" & Server.MapPath ("datab/db1.mdb")
Conn.Open

Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open "SELECT * FROM affil", Conn, 1,3

straffillink = request.form("affillink")
straffilimage = request.form("affilimage")

sql="INSERT INTO affil (link, image) VALUES ('" & straffillink & "','" & straffilimage & "')"
 
Conn.execute(sql)


set Rs = nothing
set Conn = nothing
%>
__________________
Gather. Search. Compare. Save on Hotel and Flight Prices @
Please login or register to view this content. Registration is FREE
sri_gan is offline
Reply With Quote
View Public Profile
 
Old 09-26-2007, 06:20 PM Re: edit a database
Extreme Talker

Posts: 176
Trades: 0
Quote:
Originally Posted by sri_gan View Post
Skeddles,

Here is the fixed code.



Code:
<%
 
dim sql

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.ConnectionString = "Data Source=" & Server.MapPath ("datab/db1.mdb")
Conn.Open

Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open "SELECT * FROM affil", Conn, 1,3

straffillink = request.form("affillink")
straffilimage = request.form("affilimage")

sql="INSERT INTO affil (link, image) VALUES ('" & straffillink & "','" & straffilimage & "')"
 
Conn.execute(sql)


set Rs = nothing
set Conn = nothing
%>
Syntax error in INSERT INTO statement.
/addaffil.asp, line 18
Skeddles is offline
Reply With Quote
View Public Profile
 
Old 09-26-2007, 08:04 PM Re: edit a database
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Replace

Conn.execute(sql)

with

If Request.IP = Your_IP_Address Then Response.Write("<br />" + sql + "<br />")
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 09-27-2007, 11:16 AM Re: edit a database
Skilled Talker

Posts: 97
Name: Ganesh
Trades: 0
Code:
 
<%
 
dim sql

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.ConnectionString = "Data Source=" & Server.MapPath ("datab/db1.mdb")
Conn.Open

Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open "SELECT * FROM affil", Conn, 1,3

straffillink = request.form("affillink")
straffilimage = request.form("affilimage")

if straffillink <>"" and straffilimage <>"" then
sql="INSERT INTO affil (link, image) VALUES ('" & straffillink & "','" & straffilimage & "')"
 
response.write (sql)
'Conn.execute(sql)
else
 
response.write ("affillink and affilimage are empty")

end if


set Rs = nothing
set Conn = nothing
%>
__________________
Gather. Search. Compare. Save on Hotel and Flight Prices @
Please login or register to view this content. Registration is FREE
sri_gan is offline
Reply With Quote
View Public Profile
 
Old 09-27-2007, 03:15 PM Re: edit a database
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Does either your link or your image have an apostrophe in it?

If so, you'll have to do something like:

sql="INSERT INTO affil (link, image) VALUES ('" & Replace (straffillink, "'", "''") & "','" & Replace (straffilimage, "'", "''") & "')"

Your query looks fine other than that.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 09-28-2007, 01:52 PM Re: edit a database
Skilled Talker

Posts: 97
Name: Ganesh
Trades: 0
Yeah like ADAM mentioned, single quote could be a reason.

The next code I provided will show the sql statement, play with it and let me know what do you get.
__________________
Gather. Search. Compare. Save on Hotel and Flight Prices @
Please login or register to view this content. Registration is FREE
sri_gan is offline
Reply With Quote
View Public Profile
 
Old 09-30-2007, 11:29 AM Re: edit a database
Extreme Talker

Posts: 176
Trades: 0
'c:\windows\system32\inetsrv\datab\db1.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
Skeddles is offline
Reply With Quote
View Public Profile
 
Old 09-30-2007, 11:51 AM Re: edit a database
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
That means your database has to be in the c:\windows\system32\inetsrv\datab folder and be named db1.mdb . At least one of those two things isn't true.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 10-01-2007, 07:51 PM Re: edit a database
Extreme Talker

Posts: 176
Trades: 0
Quote:
Originally Posted by ADAM Web Design View Post
That means your database has to be in the c:\windows\system32\inetsrv\datab folder and be named db1.mdb . At least one of those two things isn't true.
c:\windows\system32\inetsrv\datab\db1.mdb

well that doesnt really seem like a web adress. im not ure if thats the address of my server or not(i am using 1and1.com)

I really need to fix this though, i cant do much with my website untill its done.
Skeddles is offline
Reply With Quote
View Public Profile
 
Old 10-01-2007, 11:00 PM Re: edit a database
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
It's not a web address, and it's not supposed to be. It's supposed to be the path to your database.

Try using Server.MapPath ("datab/db1.mdb") instead.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 10-07-2007, 06:39 AM Re: edit a database
Novice Talker

Posts: 7
Trades: 0
First,check your datebase's attribute.You database may be read - only.

If your database is not a read-only one,then you must close your database first! It is important!!!! If you open a database first in a way,and then you open it again,you will not be able to open it.So before you open it again,please close it at first.
xuzheng is offline
Reply With Quote
View Public Profile
 
Old 10-10-2007, 06:04 PM Re: edit a database
Extreme Talker

Posts: 176
Trades: 0
finally got it

Last edited by Skeddles; 10-10-2007 at 09:12 PM..
Skeddles is offline
Reply With Quote
View Public Profile
 
Old 10-12-2007, 01:35 PM Re: edit a database
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
What was the answer, Skeddles? Just in case someone else has the same problem n all.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to edit a database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.63415 seconds with 12 queries