|
 |
|
|
09-25-2007, 07:07 PM
|
edit a database
|
Posts: 176
|
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, 07:21 PM
|
Re: edit a database
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
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.
|
|
|
|
09-25-2007, 09:04 PM
|
Re: edit a database
|
Posts: 5,938
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, 10:13 PM
|
Re: edit a database
|
Posts: 176
|
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, 10: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 @ Please login or register to view this content. Registration is FREE
|
|
|
|
09-25-2007, 10: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 @ Please login or register to view this content. Registration is FREE
|
|
|
|
09-26-2007, 06:20 PM
|
Re: edit a database
|
Posts: 176
|
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, 08:04 PM
|
Re: edit a database
|
Posts: 5,662
Name: John Alexander
|
Replace
Conn.execute(sql)
with
If Request.IP = Your_IP_Address Then Response.Write("<br />" + sql + "<br />")
|
|
|
|
09-27-2007, 11: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 @ Please login or register to view this content. Registration is FREE
|
|
|
|
09-27-2007, 03:15 PM
|
Re: edit a database
|
Posts: 5,938
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, 01: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 @ Please login or register to view this content. Registration is FREE
|
|
|
|
09-30-2007, 11:29 AM
|
Re: edit a database
|
Posts: 176
|
'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, 11:51 AM
|
Re: edit a database
|
Posts: 5,938
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, 07:51 PM
|
Re: edit a database
|
Posts: 176
|
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, 11:00 PM
|
Re: edit a database
|
Posts: 5,938
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, 06: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, 06:04 PM
|
Re: edit a database
|
Posts: 176
|
finally got it
Last edited by Skeddles; 10-10-2007 at 09:12 PM..
|
|
|
|
10-12-2007, 01:35 PM
|
Re: edit a database
|
Posts: 5,662
Name: John Alexander
|
What was the answer, Skeddles? Just in case someone else has the same problem n all.
|
|
|
|
|
« Reply to edit a database
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|