Current location: Hot Scripts Forums » Programming Languages » PHP » Access to SQL Script conversion


Access to SQL Script conversion

Reply
  #1 (permalink)  
Old 11-14-03, 10:01 AM
PaniXOH PaniXOH is offline
New Member
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Access to SQL Script conversion

Hello,

I have a script that I use for a newsletter. It uses an Access database. Well, now I changed web hosts, and I need to convert it so that it will use an SQL database. I know most of what I need to do, and I even already have the database converted over to SQL, I just need to figure out how to get the script to connect to the SQL database.

First off, I know that I need to change the line that the access database connects to to;
connect_string = "Driver={Mysql}; Server=localhost; Database=testDB; UID=testUser; PWD=testUserPass"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open(connect_string)


I believe I am replacing just this line from what I have been told;
Conn.Open "DBQ=" & Server.MapPath("newsletter.mdb")& ";Driver={Microsoft Access Driver (*.mdb)}"


Here is the code for one of the files.

-----------------------------------------------------------------
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 100
Response.AddHeader "cache-control", "private"
Response.AddHeader "pragma", "no-cache"

'based on routine from visualbuilder
Function checkMail(sCheckEmail)
Dim isValidMail, location
checkMail = True
isValidMail = Trim(sCheckEmail)
location = InStr(1, isValidMail, "@")

If Not (location > 1 And (InStrRev(isValidMail, ".") > location + 1)) Then
checkMail = False
ElseIf InStr(location + 1, isValidMail, "@") > location Then
checkMail = False
ElseIf Mid(isValidMail, location + 1, 1) = "." Then
checkMail = False
ElseIf InStr(1, Right(isValidMail, 2), ".") > 0 Then
checkMail = False
End If
End Function

'declare our constants
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdTable = &H0002
'our variables
Dim strEmail, objRS , objConn
'get email address from form
strEmail = Request.Form("email")
strEmail = lcase(strEmail)

dim strList
strList = ucase(request.form("list"))
if strList="" then strList="NEWSLETTER"

'check email
validemail = checkMail(strEmail)
If validemail = False Then
'if invalid stay on this page
Response.Redirect ("http://www.glenlaurel.com/news/newsletter.asp")
Else
'create the connection object and open it
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DBQ=" & Server.MapPath("http://www.glenlaurel.com/news/newsletter.mdb")& ";Driver={Microsoft Access Driver (*.mdb)}"

'create recordset object and open it
Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.Open "email" ,objConn ,adopenStatic, adLockOptimistic, adCmdTable
'add new entry
objRS.AddNew
'response.write "huh?"
objRS("email") = strEmail
objRS("list")=strList
'update recordset
objRS.Update
'close everything
objRS.Close
'delete object variables
Set objRS = Nothing

objRS = "DELETE * FROM NoEmail WHERE email = '" +strEmail + "'"
objConn.execute objRS
objConn.Close

Set objConn = Nothing


End If
Response.Redirect ("http://www.glenlaurel.com/home.asp")
%>

-----------------------------------------------------------


If you show me/tell me what I have to change I can probably figure out how to fix the rest of them. If you have access and would like to look at them the links for them are in http://www.glenlaurel.com/asptosql/

You should be able to download and look at them from there.

PLEASE HELP !
Reply With Quote
  #2 (permalink)  
Old 11-16-03, 06:30 AM
Stefan's Avatar
Stefan Stefan is offline
Junior Code Guru
 
Join Date: Jun 2003
Location: Utrecht, The Netherlands
Posts: 599
Thanks: 0
Thanked 0 Times in 0 Posts
it looks like you're using ADODB in which case I believe (but am not sure) that you only need to change the database type to MySQL for it to work correctly. you might want to check the ADODB documentation to make sure though.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a good review management script griz_fan Script Requests 10 07-29-07 05:08 AM
Script Conversion: Access Database/Now to SQL PaniXOH ASP 1 11-14-03 09:35 PM
Looking for Registered Members area access to files .. script zamen Script Requests 3 09-02-03 05:44 AM
ASP Calendar..HELP...pls jimthepict ASP 1 07-31-03 05:01 PM
change my field in this example sal21 ASP 3 07-14-03 02:49 AM


All times are GMT -5. The time now is 05:45 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.