Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating two databases

Status
Not open for further replies.

Ragol1

Programmer
Oct 25, 2001
315
US
Below is the code i use to update a database within my site the fields on the for are UserID,Password,Email.
This works ok but I would like to update another database with just the UserID and Email.
The fields in the new database are called "Name" and "Email" and the table is called "Users" I would like to update Name with what is put in UserID and Email with what is put in Email.
Any help would be great.

Response.Buffer = true
dim cnn,rst
set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=E:/site1/database.mdb;"
sqltext = "SELECT * FROM site1"
rst.Open sqltext,cnn,3,3

dim UserID,Password,Email
UserID = Request.Form("UserID")
Password = Request.Form("Password")
Email = Request.Form("Email")

rst.AddNew
rst("UserID") = UserID
rst("Password")= Password
rst("Email") = Email
rst.update
%>
 
add this:

set cnn2 = Server.CreateObject("ADODB.Connection")
set rst2 = Server.CreateObject("ADODB.RecordSet")
cnn2.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=E:/site1/(insert other database name here).mdb;"
sqltext = "SELECT * FROM Users"
rst2.Open sqltext,cnn2,3,3

dim UserID,Password,Email
UserID = Request.Form("UserID")
Password = Request.Form("Password")
Email = Request.Form("Email")

rst.AddNew
rst("Name") = UserID
rst("Email") = Email
rst.update
%>
 
Thanks but something is still wrong I added the code but it blows up on me the database is in the same directory so it has rights just like the other one..
Any ideas

Response.Buffer = true
dim cnn,rst
set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=E:/site1/Database.mdb;"
sqltext = "SELECT * FROM Site1"
rst.Open sqltext,cnn,3,3


dim UserID,Password,Email
UserID = Request.Form("UserID")
Password = Request.Form("Password")
Email = Request.Form("Email")

rst.AddNew
rst("UserID") = UserID
rst("Password")= Password
rst("Email") = Email
rst.update

<<--------works ok up until this point--------->

set cnn2 = Server.CreateObject(&quot;ADODB.Connection&quot;)
set rst2 = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
cnn2.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=E:/site1/users.mdb;&quot;
sqltext = &quot;SELECT * FROM users&quot;
rst2.Open sqltext,cnn2,3,3

dim UserID,Email
UserID = Request.Form(&quot;UserID&quot;)
Email = Request.Form(&quot;Email&quot;)

rst.AddNew
rst(&quot;Name&quot;) = UserID
rst(&quot;Email&quot;) = Email
rst.update
%>
 
I added this above set cnn2 but still didnt work
Response.Buffer = true
dim cnn2,rst2
does rst,Addnew need to be rst2.Addnew
 
rst2.AddNew
rst2(&quot;Name&quot;) = UserID
rst2(&quot;Email&quot;) = Email
rst2.update
 
Have tried it still doesnt work

Response.Buffer = true
dim cnn2,rst2
set cnn2 = Server.CreateObject(&quot;ADODB.Connection&quot;)
set rst2 = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
cnn2.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=E:/site1/users.mdb;&quot;
sqltext = &quot;SELECT * FROM users&quot;
rst2.Open sqltext,cnn2,3,3

dim UserID,Email
UserID = Request.Form(&quot;UserID&quot;)
Email = Request.Form(&quot;Email&quot;)

rst2.AddNew
rst2(&quot;Name&quot;) = UserID
rst2(&quot;Email&quot;) = Email
rst2.update
%>
 
Http internal server error 500 when i take the extra piece of code out it works fine..
 
could you update your browser settings to show friendly HTTP error messages?

in IE, select Tools, Internet Options, Advanced, then scroll to that setting.

then try it again and it should give you a better error description.
 
Ok it was already on friendly errors I have changed the name field in my database to be UserID also just so we dont confuse the matter. here is where its at so far
We must be over looking something the database has rights and the fields are correct.


Response.Buffer = true
dim cnn,rst
set cnn = Server.CreateObject(&quot;ADODB.Connection&quot;)
set rst = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
cnn.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=E:/site1/database.mdb;&quot;
sqltext = &quot;SELECT * FROM Site1&quot;
rst.Open sqltext,cnn,3,3


dim UserID,Password,Email
UserID = Request.Form(&quot;UserID&quot;)
Password = Request.Form(&quot;Password&quot;)
Email = Request.Form(&quot;Email&quot;)

rst.AddNew
rst(&quot;UserID&quot;) = UserID
rst(&quot;Password&quot;)= Password
rst(&quot;Email&quot;) = Email
rst.update

<-----if i take the below code out it works----->

Response.Buffer = true
dim cnn2,rst2
set cnn2 = Server.CreateObject(&quot;ADODB.Connection&quot;)
set rst2 = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
cnn2.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=E:/site1/users.mdb;&quot;
sqltext = &quot;SELECT * FROM users&quot;
rst2.Open sqltext,cnn2,3,3

dim UserID,Email
UserID = Request.Form(&quot;UserID&quot;)
Email = Request.Form(&quot;Email&quot;)

rst2.AddNew
rst2(&quot;UserID&quot;) = UserID
rst2(&quot;Email&quot;) = Email
rst2.update
%>
 
try removing

dim UserID,Email
UserID = Request.Form(&quot;UserID&quot;)
Email = Request.Form(&quot;Email&quot;)

from the second db processing....
 
Thank you it worked I had the fist dim,UserID,Password,Email cause I validated the fields with
if Email = &quot;&quot; then
error = &quot;You have not entered an Email address.please click back&quot;
Response.Write error
Response.End
end if

If UserID = &quot;&quot; then
error = &quot;You have not entered a name.Please click back&quot;
Response.Write error
Response.End
end if

If Password = &quot;&quot; then
error = &quot;You have not entered a Password.Please click back&quot;
Response.Write error
Response.End
end if

Thank you once again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top