i have a connection:
and i have this code below which is working with an access database.. my problem is, i have tryed changing cn to conn but it still doesnt work.. could anyone suggest what i should do? or help me code this? pretty pleaseCode:<!--#include file="adovbs.inc"--> <% Response.Expires = -1500 Response.Buffer = true Server.ScriptTimeout = 100 Session.Timeout = 90 'Create an ADO connection object set conn=Server.CreateObject("ADODB.Connection") strSQLServerName = "XXXXXXX" 'Holds the name of the SQL Server (This is the name/location or IP address of the SQL Server) strSQLDBUserName = "SA" 'Holds the user name (for SQL Server Authentication) strSQLDBPassword = "test" 'Holds the password (for SQL Server Authentication) strSQLDBName = "db2SQL" 'Initilise the DB Connection String conn.open = "provider=SQLOLEDB; Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";" %>
Code:<% Dim submit1, oldpassword, newpassword, confirmpassword submit1 = Server.HTMLEncode(Request.Form("submit1")) oldpassword = Request.Form("oldpassword") newpassword = Request.Form("newpassword") confirmpassword = Request.Form("confirmpassword") 'If submit1 = "confirmpassword" Then Dim sc, cn, rs, sql sc = "driver={Microsoft Access Driver (*.mdb)};dbq=" _ & Server.MapPath("../DB/H2.mdb") Set cn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset") cn.Open conn sql = "SELECT [password] FROM [member] " _ & "WHERE [username] = '" & Request.Form("username") & "'" rs.Open sql, cn, 1 If oldpassword = "" Or newpassword = "" Then Response.Write "Make sure password is valid and fill all the fields please!" ElseIf rs("password") <> oldpassword Then Response.Write "Wrong password inserted!" ElseIf newpassword <> confirmpassword Then Response.Write "Confirm password and new password are not the same!" ElseIf oldpassword = newpassword Then Response.Write "Old password and new password are the same!" Else sql = "UPDATE mem SET password = '" & newpassword & "' WHERE " _ & "username = '" & Request.Form("username") & "'" cn.Execute(sql) Response.Write "Your Password has been changed!" End If rs.Close Set rs = Nothing cn.Close conn.close Set cn = Nothing 'End If %>



LinkBack URL
About LinkBacks

Reply With Quote

Bookmarks