Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2005
    Posts
    31

    Unanswered: what changes to access code to work in mysql (was "Urgent advice needed")

    I recently migrated my access database to mysql, and now I have to reset the connections on my web site pages and alter the quiries, I have no problem reseting the connection, but I'm not sure what other changes need to be made so I was hoping that someone here would be able to give me a bit of advice as to what changes need to be made to the pages code, what are the major differences. I'm posting the code aswell to show what my pages are like, I'm not asking anyone to do this for me but if someone could point me in the right direction I would really appreciate it because I just don't know where to start. Thanks for reading my post
    Code:
    <%
    	Dim thumbs(7), text(20), pagenos, info, image
    	Dim search, uid, pagenumber, productset, grade, startcharacter
    	Dim strQuery, objRS, objConn, filePath
    	Dim i, number, remainders
    	Dim pages, desc, code, price, startcharacterstring, instock, details, units
    
    	grade = Request.QueryString("grade")
    	startcharacter = Request.QueryString("startcharacter")
    	productset = Request.QueryString("productset")
    	search = Request.QueryString("search")
    	uid = Request.QueryString("uid")
    	pagenumber = Request.QueryString("pagenumber")
    	startcharacterstring = Server.URLEncode(startcharacter)
    
    	Set objConn = Server.CreateObject("ADODB.Connection")
    	filePath = Server.MapPath("..\database.mdb")
    	Set objConn = Server.CreateObject("ADODB.Connection")
    	objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath
    	
    	If pagenumber = "" Then
    		pagenumber = 1
    	End If
    	
    	If startcharacter <> "" Then
    		startcharacter = mid(startcharacter,23)
    	End If
    	If grade = "" AND startcharacter = "" AND productset = "" Then
    		strQuery = "SELECT * FROM Comics"
    	Else
    		strQuery = "SELECT * FROM Comics WHERE "
    		If grade <> "" Then
    			strQuery = strQuery & "Grade = '" & grade & "'"
    		End If
    		If productset <> "" Then
    			If grade <> "" Then
    				strQuery = strQuery & " AND ProductGroup = '" & productset & "'"
    			Else
    				strQuery = strQuery & "ProductGroup = '" & productset & "'"
    			End If
    		End If
    		If startcharacter <> "" Then
    			If grade <> "" OR productset <> "" Then
    				strQuery = strQuery & " AND ProductName LIKE '" & startcharacter & "%' ORDER BY ProductName, Description ASC;"
    			Else
    				strQuery = strQuery & "ProductName LIKE '" & startcharacter & "%'ORDER BY ProductName, Description ASC;"
    			End If
    		End If
    	End If
    	'Response.Write("<FONT COLOR=#FFFFFF>" & strQuery & "</FONT>")
    	Set objRS=Server.CreateObject("ADODB.Recordset")
    	objRS.Open strQuery,objConn,3,3
    	
    	If NOT objRS.EOF Then
    		number = objRS.recordcount
    		pages = number / 20
    		pages = fix(pages)
    		remainders = number MOD 20
    		If remainders = 0 Then
    		Else
    			remainders = 1
    		End If
    		pagenos = ""
    		If pages > 10 Then
    			pagenos = "<P ALIGN=CENTER><FORM METHOD=GET ACTION=" & Request.ServerVariables("SCRIPT_NAME") & ">"
    			pagenos = pagenos & "<INPUT TYPE=HIDDEN NAME=grade VALUE=" & grade & ">"
    			pagenos = pagenos & "<INPUT TYPE=HIDDEN NAME=startcharacter VALUE=" & startcharacterstring & ">"
    			pagenos = pagenos & "<INPUT TYPE=HIDDEN NAME=productset VALUE=" & productset & ">"
    			pagenos = pagenos & "<SELECT SIZE=6 NAME=pagenumber onchange=this.form.submit()>"
    				For i = 1 to (pages + remainders)
    					pagenos = pagenos & "<OPTION"
    					If i = cint(pagenumber) Then
    						pagenos = pagenos & " SELECTED"
    					End If
    					pagenos = pagenos & ">" & i & "</OPTION>"
    				Next
    			pagenos = pagenos & "</SELECT></FORM></P>"
    		ElseIf pages > 10 Then
    			For i = 1 to (pages + remainders)
    				If i mod 20 = 0 Then
    					pagenos = pagenos & "<BR>"
    				End If
    				pagenos = pagenos & "<A HREF=" & Request.ServerVariables("SCRIPT_NAME")
    				pagenos = pagenos & "?productset=" & productset & "&pagenumber="
    				pagenos = pagenos & i & "&startcharacter=" & startcharacterstring
    				pagenos = pagenos & "&grade=" & grade & ">" & i & "</A>&nbsp"
    			Next
    		Else
    			For i = 1 to (pages + remainders)
    				pagenos = pagenos & "<A HREF=" & Request.ServerVariables("SCRIPT_NAME")
    				pagenos = pagenos & "?productset=" & productset & "&pagenumber="
    				pagenos = pagenos & i & "&startcharacter=" & startcharacterstring
    				pagenos = pagenos & "&grade=" & grade & ">" & i & "</A>&nbsp"
    			Next
    		End If
    		
    		i = 0
    		While( i < ( (pagenumber - 1) * 20) )
    			objRS.MoveNext
    			i = i + 1
    		Wend
    		uid = objRS("uid")
    		For i = 0 to 20
    			If NOT objRS.EOF Then
    				text(i) = "<A HREF=" & Request.ServerVariables("SCRIPT_NAME")
    				text(i) = text(i) & "?uid=" & objRS("UID") & "&productset="
    				text(i) = text(i) & productset & "&pagenumber="
    				text(i) = text(i) & pagenumber & "&startcharacter=" & startcharacterstring
    				text(i) = text(i) & "&grade=" & grade & "><FONT COLOR=#FFFFFF>"
    				text(i) = text(i) & objRS("ProductName") & " " & objRS("Description")
    				text(i) = text(i) & "</FONT></A>"
    				objRS.MoveNext
    			End If
    		Next
    	End If
    
    	If Request.QueryString("uid") <> "" Then
    		uid = Request.QueryString("uid")
    	End If
    	
    	strQuery = "SELECT * FROM Comics WHERE UID='" & uid & "';"
    	Set objRS = objConn.Execute(strQuery)
    	If NOT objRS.EOF Then
    		image = objRS("Images")
    		info = "<P ALIGN=CENTER>"
    		info = info & objRS("ProductName") & "<BR>" & objRS("ProductType") & "<BR>"
    		info = info & objRS("Description") & " " & objRS("Year") & "<BR>"
    		info = info & "Grade " & objRS("Grade") & "<BR>"
    		info = info & "WAS" & " " & "" &  FormatNumber(objRS("UnitPrice"), 2) & "<BR>" & objRS("SaleInfo") & "<BR>"
                    info = info & "NOW" & " " & "" &  FormatNumber(objRS("SalePrice"), 2) & "<BR></P>"
    		desc = objRS("ProductName")
    		price = objRS("SalePrice")
    		code = objRS("UID")
    		instock = objRS("UnitsInStock")
    		details = objRS("ProductName") & "-" & objRS("Description") & "-" & objRS("grade")
    		units = objRS("Units")
    	End If
    	
    	objConn.Close
    %>
    Last edited by MAZER; 03-24-06 at 10:51.

  2. #2
    Join Date
    Aug 2005
    Posts
    31

    update

    I eventually got it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •