Whing Dela Cruz
asked on
Save data in two Database, Asp
Hi experts, I wish to save a certain data into two DataBase. I have sOrder and xOrder Database. I want my code below can execute two actions by saving the data into two database. Is it possible? If not, is there any other way to meet the goal? Thank you!
<%
dim pname,pcode
pname = "Mango"
pcode = "8900"
'I have two DataBase sOrder and xOrder the two has a commom table name, Stock. I wish to save here the data in a two database.
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
cn.ConnectionString = "driver={SQL Server};server=PCSERVER;uid=;pwd=;DataBase=sOrder"
cn.Open
Set rs = cn.Execute("Select Procode, Proname From Stock where Procode='" & pcode & "'")
with rs
If .BOF = True And .EOF = True Then
cn.execute("Insert into(Procode,Proname) values('" & pcode & "','" & replace(pname, "'","''") & "')")
cn.close
set cn = nothing
response.write("Saved!")
Response.End()
Else
Response.End()
end if
End with
Set rs = nothing
cn.close
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER