|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Converting to DSN-less connection (Please HELP!!!)
<i><b>Originally posted by : Scott (scott@bhamnow.com)</b></i><br /> I am trying to re-code an existing application from using a DSN connection over to using a DSN-less connection.<br /><br />There are several scripts that still refer to the DSN connection and I have managed to recode most of them to the new DSN-less scripts. I have hit a wall with one set of scripts though.<br /><br /><br />Here's the related code:<br /><br />Assuming that my new DSN-less connection script is:<br /><%<br />****StrConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=E
athtodatabasecgi-binproducts.mdb"<br />****Set conn = Server.CreateObject("ADODB.Connection")<br />****conn.Open StrConnect<br />%><br /><br />What changes to the following code would be neccesary in order to use the above connection script in place of the system DSN "cart" connection that is being used here:<br /><br /><br /><%<br />****Set conn = Server.CreateObject("ADODB.Connection")<br />****conn.open "cart","",""<br />****Set Session("cart_conn") = conn<br /><br />****<br />%><br /><%<br />sql = "INSERT INTO TblOrderHeader (ID, firstname, lastname, addressline1, addressline2, city, state, zip, country, phone, fax, email, cctype, ccnameoncard, ccexpiration, ccnumber, comments, dateshipped)"<br /><br /><br />sql = sql & " VALUES('" &CustID& "','" &firstname& "','" &lastname& "','" &addressline1& "','" &addressline2& "','" &city& "','" &state& "','" &zip& "','" &country& "','" &phone& "','" &fax& "','" &email& "','" &cctype& "','" &ccnameoncard& "','" &ccexpiration& "','" &ccnumber& "','" &comments& "','" &dateshipped& "');"<br /><br />set conn=conn.Execute(sql)<br />%><br /><br /><br /><br /><% <br />strOrderInfo = Session("MyProductsArray")<br />Session("MyProductsArray")=strOrderInfo<br />Session("DupCheck")=Session("DupCheck")<br />%><br /><br /><br /><%<br />************** Public strProductsArray<br />************** strProductsArray = Split(strOrderInfo,",")<br />************** %><br /><br /><br /><%<br />****Set conn = Server.CreateObject("ADODB.Connection")<br />****conn.open "cart","",""<br />****Set Session("cart_conn") = conn<br />%><br />*****<br />********** <br /><br />**********<% For i = 0 to UBound(strProductsArray)-1%><br /><br /><%<br />set rs=conn.Execute("SELECT TblPrducts.ProductName, TblPrducts.ProductPrice FROM TblPrducts WHERE TblPrducts.ProductCode='"&strProductsArray(i)&"'")<br />%><br /><br /><%PN=rs("ProductName")%><br /><%Newname8=""%><br /><%s=Len(PN)%><br /><%a=1%><br /><%do while a<=s%><br /><%Textchar = Mid(PN,a,1)%><br /><%if Textchar = "'"then%><br /><%Newname8=Newname8 & Textchar & "'"%><br /><%else%><br /><%Newname8=Newname8 & Textchar%><br /><%end if%><br /><%a=a+1%><br /><%loop%><br /><%PN = Newname8%><br /><br /><br /><br /><br /><%<br />sql = "INSERT INTO TblOrderItems (ID, ProductCode, Quantity, ProductName, ProductPrice, DateShipped)"<br /><br /><br />sql = sql & " VALUES('" &CustID& "','" &strProductsArray(i)& "','" &strProductsArray(i+1)& "','" &PN& "','" &rs("ProductPrice")& "','"&dateshipped& "');"<br /><br /><br />conn.Execute(sql)<br />%><br /><br />*************************<br /><br />******* **********<% i = i+1%><br />******* **********<% next %><br /><br /><%i=0%><br /><br /><%conn.close%> |
|
#2
|
|||
|
|||
|
<i><b>Originally posted by : steve</b></i><br />Wow! what i do at aspfree is use an include file with the strConn = "My conn string" <br /><br />at the top of each page i do<br /><!--#include file="conn.asp"--><br /><br />'in my connection code i do this--The connection 'string needed is in the include file and automatically referenced in the .open line.<br /><br /><br />set strConnect = server.createobject("adodb.connection")<br />strConnect.open strConn <br /><br /><br />Note: I would limit putting objects into session objects. This isn't very scalable and doesn't use hardware resources very well. hope this helps!<br /><br />steve<br /><br /><br />------------<br />Scott at 3/11/2000 1:32:10 PM<br /><br /> I am trying to re-code an existing application from using a DSN connection over to using a DSN-less connection.<br /><br />There are several scripts that still refer to the DSN connection and I have managed to recode most of them to the new DSN-less scripts. I have hit a wall with one set of scripts though.<br /><br /><br />Here's the related code:<br /><br />Assuming that my new DSN-less connection script is:<br /><%<br />****StrConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=E
athtodatabasecgi-binproducts.mdb"<br />****Set conn = Server.CreateObject("ADODB.Connection")<br />****conn.Open StrConnect<br />%><br /><br />What changes to the following code would be neccesary in order to use the above connection script in place of the system DSN "cart" connection that is being used here:<br /><br /><br /><%<br />****Set conn = Server.CreateObject("ADODB.Connection")<br />****conn.open "cart","",""<br />****Set Session("cart_conn") = conn<br /><br />****<br />%><br /><%<br />sql = "INSERT INTO TblOrderHeader (ID, firstname, lastname, addressline1, addressline2, city, state, zip, country, phone, fax, email, cctype, ccnameoncard, ccexpiration, ccnumber, comments, dateshipped)"<br /><br /><br />sql = sql & " VALUES('" &CustID& "','" &firstname& "','" &lastname& "','" &addressline1& "','" &addressline2& "','" &city& "','" &state& "','" &zip& "','" &country& "','" &phone& "','" &fax& "','" &email& "','" &cctype& "','" &ccnameoncard& "','" &ccexpiration& "','" &ccnumber& "','" &comments& "','" &dateshipped& "');"<br /><br />set conn=conn.Execute(sql)<br />%><br /><br /><br /><br /><% <br />strOrderInfo = Session("MyProductsArray")<br />Session("MyProductsArray")=strOrderInfo<br />Session("DupCheck")=Session("DupCheck")<br />%><br /><br /><br /><%<br />************** Public strProductsArray<br />************** strProductsArray = Split(strOrderInfo,",")<br />************** %><br /><br /><br /><%<br />****Set conn = Server.CreateObject("ADODB.Connection")<br />****conn.open "cart","",""<br />****Set Session("cart_conn") = conn<br />%><br />*****<br />********** <br /><br />**********<% For i = 0 to UBound(strProductsArray)-1%><br /><br /><%<br />set rs=conn.Execute("SELECT TblPrducts.ProductName, TblPrducts.ProductPrice FROM TblPrducts WHERE TblPrducts.ProductCode='"&strProductsArray(i)&"'")<br />%><br /><br /><%PN=rs("ProductName")%><br /><%Newname8=""%><br /><%s=Len(PN)%><br /><%a=1%><br /><%do while a<=s%><br /><%Textchar = Mid(PN,a,1)%><br /><%if Textchar = "'"then%><br /><%Newname8=Newname8 & Textchar & "'"%><br /><%else%><br /><%Newname8=Newname8 & Textchar%><br /><%end if%><br /><%a=a+1%><br /><%loop%><br /><%PN = Newname8%><br /><br /><br /><br /><br /><%<br />sql = "INSERT INTO TblOrderItems (ID, ProductCode, Quantity, ProductName, ProductPrice, DateShipped)"<br /><br /><br />sql = sql & " VALUES('" &CustID& "','" &strProductsArray(i)& "','" &strProductsArray(i+1)& "','" &PN& "','" &rs("ProductPrice")& "','"&dateshipped& "');"<br /><br /><br />conn.Execute(sql)<br />%><br /><br />*************************<br /><br />******* **********<% i = i+1%><br />******* **********<% next %><br /><br /><%i=0%><br /><br /><%conn.close%> |
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > Converting to DSN-less connection (Please HELP!!!) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|