 |
09-25-2007, 06:07 PM
|
edit a database
|
Posts: 77
|
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?
|
|
|
|
09-25-2007, 06:21 PM
|
Re: edit a database
|
Posts: 1,850
Name: Thierry
Location: In the void
|
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...
__________________
Listen to the ducky: "This is awesome!!!"
|
|
|
|
09-25-2007, 08:04 PM
|
Re: edit a database
|
Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
|
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).
|
|
|
|
09-25-2007, 09:13 PM
|
Re: edit a database
|
Posts: 77
|
Quote:
Originally Posted by ADAM Web Design
|
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.
|
|
|
|
09-25-2007, 09:14 PM
|
Re: edit a database
|
Posts: 97
Name: Ganesh
|
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 @ www.vtrip.info
|
|
|
|
09-25-2007, 09:17 PM
|
Re: edit a database
|
Posts: 97
Name: Ganesh
|
Quote:
Originally Posted by Skeddles
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 @ www.vtrip.info
|
|
|
|
09-26-2007, 05:20 PM
|
Re: edit a database
|
Posts: 77
|
Quote:
Originally Posted by sri_gan
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
|
|
|
|
09-26-2007, 07:04 PM
|
Re: edit a database
|
Posts: 4,712
Name: John Alexander
|
Replace
Conn.execute(sql)
with
If Request.IP = Your_IP_Address Then Response.Write("<br />" + sql + "<br />")
|
|
|
|
09-27-2007, 10:16 AM
|
Re: edit a database
|
Posts: 97
Name: Ganesh
|
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 @ www.vtrip.info
|
|
|
|
09-27-2007, 02:15 PM
|
Re: edit a database
|
Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
|
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.
|
|
|
|
09-28-2007, 12:52 PM
|
Re: edit a database
|
Posts: 97
Name: Ganesh
|
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 @ www.vtrip.info
|
|
|
|
09-30-2007, 10:29 AM
|
Re: edit a database
|
Posts: 77
|
'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.
|
|
|
|
09-30-2007, 10:51 AM
|
Re: edit a database
|
Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
|
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.
|
|
|
|
10-01-2007, 06:51 PM
|
Re: edit a database
|
Posts: 77
|
Quote:
Originally Posted by ADAM Web Design
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.
|
|
|
|
10-01-2007, 10:00 PM
|
Re: edit a database
|
Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
|
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.
|
|
|
|
10-07-2007, 05:39 AM
|
Re: edit a database
|
Posts: 7
|
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.
|
|
|
|
10-10-2007, 05:04 PM
|
Re: edit a database
|
Posts: 77
|
finally got it
Last edited by Skeddles : 10-10-2007 at 08:12 PM.
|
|
|
|
10-12-2007, 12:35 PM
|
Re: edit a database
|
Posts: 4,712
Name: John Alexander
|
What was the answer, Skeddles? Just in case someone else has the same problem n all.
|
|
|
|
|
« Reply to edit a database
|
|
|
|