Hi,
I'd been using MS Access as my database in ASP until recently when I switched to MySQL. It's been working well but I have problems with this particular querry.
The code below works ok(returns records) when I use the Access database,
Set cn = Server.CreateObject("ADODB.Connection"
Constr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= " & Server.MapPath("./Data/lecturers.mdb"
& ";Persist Security Info=False"
cn.Connectionstring = Constr
cn.Open
If Request.Form("txtSearch"
<> "" Then
Searchstr = Request.Form("txtSearch"
Else
Searchstr = Request.QueryString("Search"
End If
strSQL = "Select ID, Surname, Other_names, Title, telephone, Email, "
strSQL = strSQL & "Department, Centre From Contacts Where Surname Like "
strSQL = strSQL & "'" & Searchstr & "%'"
Set rs = Server.CreateObject("ADODB.Recordset"
rs.open strSQL, cn, adOpenStatic, adLockOptimistic, adCmdText
...But then using MySQL as shown below my querry returns nothing, with the record counter showing -1.
Set cn = createobject("ADODB.Connection"
cn.open = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_
& "DATABASE=staff_list;"_
& "UID=root;PWD=; OPTION=35;"
If Request.Form("txtSearch"
<> "" Then
Searchstr = Request.Form("txtSearch"
Else
Searchstr = Request.QueryString("Search"
End If
strSQL = "Select ID, Surname, Other_names, Title, telephone, Email, "
strSQL = strSQL & "Department, Centre From Contacts Where Surname Like "
strSQL = strSQL & "'" & Searchstr & "%'"
Set rs = Server.CreateObject("ADODB.Recordset"
rs.open strSQL, cn, adOpenStatic, adLockOptimistic, adCmdText
Can someone pleases tell me what's happening?
I'd been using MS Access as my database in ASP until recently when I switched to MySQL. It's been working well but I have problems with this particular querry.
The code below works ok(returns records) when I use the Access database,
Set cn = Server.CreateObject("ADODB.Connection"
Constr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= " & Server.MapPath("./Data/lecturers.mdb"
cn.Connectionstring = Constr
cn.Open
If Request.Form("txtSearch"
Searchstr = Request.Form("txtSearch"
Else
Searchstr = Request.QueryString("Search"
End If
strSQL = "Select ID, Surname, Other_names, Title, telephone, Email, "
strSQL = strSQL & "Department, Centre From Contacts Where Surname Like "
strSQL = strSQL & "'" & Searchstr & "%'"
Set rs = Server.CreateObject("ADODB.Recordset"
rs.open strSQL, cn, adOpenStatic, adLockOptimistic, adCmdText
...But then using MySQL as shown below my querry returns nothing, with the record counter showing -1.
Set cn = createobject("ADODB.Connection"
cn.open = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_
& "DATABASE=staff_list;"_
& "UID=root;PWD=; OPTION=35;"
If Request.Form("txtSearch"
Searchstr = Request.Form("txtSearch"
Else
Searchstr = Request.QueryString("Search"
End If
strSQL = "Select ID, Surname, Other_names, Title, telephone, Email, "
strSQL = strSQL & "Department, Centre From Contacts Where Surname Like "
strSQL = strSQL & "'" & Searchstr & "%'"
Set rs = Server.CreateObject("ADODB.Recordset"
rs.open strSQL, cn, adOpenStatic, adLockOptimistic, adCmdText
Can someone pleases tell me what's happening?