Results 1 to 3 of 3

Thread: HELP!!!

  1. #1
    Charles Guest

    Default HELP!!!

    Hello, I&#039;m passing a userID and Password to component and I&#039;m suppose to return an AccountNumber from the component which uses<BR>a stored procedure, but I&#039;m not getting the AccountNumber for the<BR>userID and Password entered, can you Please look at my code and tell me what I&#039;m doing wrong? When I hard code the userID and Password in the SQL of the stored procedure it works OK.<BR><BR>Thanks,<BR>ASP<BR>***<BR>&#060;%<BR> Response.Buffer = true<BR> Dim oRS<BR> Dim conn<BR> Dim rID<BR> Dim sql<BR> Dim var2 <BR> <BR> userID = Request.Form("xuserID")<BR> Password = Request.Form("Pwd")<BR> Set var1 = Server.CreateObject("SNCls3.SNOrderDir3")<BR> var2 = var1.Clogx(userID, Password)<BR> Response.Write var2 <BR> &#039; If var2 &#060;&#062; "" Then <BR> &#039;varx = var2<BR> &#039;session("user") = varx<BR> &#039;response.redirect("main.asp")<BR> &#039;Else <BR> &#039;Response.Redirect "Login.asp?info=" & CODELOGIN <BR> &#039;End if <BR>%&#062;<BR><BR>COM<BR>***<BR>Public Function Clogx(userID, Password) As String<BR>&#039;SETTING MTS OBJECT<BR> Dim objOContext As ObjectContext<BR> Set objOContext = GetObjectContext()<BR> <BR> &#039;DECLARING ERROR MESSAGE VARIABLES<BR> Dim lErrNo As Long<BR> Dim sErrDesc As String<BR> On Error GoTo ErrorHandler<BR> <BR> &#039;SET ADO OBJECTS<BR> Dim objConn As New ADODB.connection<BR> Dim objRS As New ADODB.recordset<BR> Dim objCommand As New ADODB.Command<BR> Dim objParam As New ADODB.Parameter<BR> <BR> &#039;OPEN CONNECTION AND DATABASE<BR> With objConn<BR> .ConnectionString = DB_CONNECTIONSTRING<BR> .Open<BR> End With<BR> <BR> &#039; USE COMMAND OBJECT TO CALL STORED PROCEDURE<BR> With objCommand<BR> .CommandText = "spLogin"<BR> .CommandType = adCmdStoredProc<BR> .ActiveConnection = objConn<BR> End With<BR> <BR> &#039; PASS ACCOUNTNUMBER TO STORED PROCEDURE<BR> Set objParam = objCommand.CreateParameter("@userID", adVarChar, adParamInput, 15, userID)<BR> objCommand.Parameters.Append objParam<BR> Set objParam = objCommand.CreateParameter("@Password", adVarChar, adParamInput, 15, Password)<BR> objCommand.Parameters.Append objParam<BR> Set objRS = objCommand.Execute<BR> &#039;SET METHOD EQUAL TO RECORDSET OBJECT<BR> &#039;objRS.MoveFirst<BR> &#039;CHECKING = objRS.Fields("AccountNumber")<BR> objRS.MoveFirst<BR> Clogx = objRS.Fields("AccountNumber")<BR> objRS.Close<BR> <BR> &#039;Using MTS to complete transaction<BR> &#039;objOContext.SetComplete<BR> <BR> &#039;Closing connections<BR>&#039; Set objRS = Nothing<BR>&#039; Set objOContext = Nothing<BR>&#039; Set objParam = Nothing<BR>&#039; Set objConn = Nothing<BR>&#039; Set objCommand.ActiveConnection = Nothing<BR> Exit Function<BR> <BR> &#039; USING MTS TO ABORT TRANSACTION<BR>ErrorHandler:<BR> &#039; Store incoming values<BR> lErrNo = Err.Number<BR> sErrDesc = Err.Description<BR> <BR> &#039; Allow resume next after error<BR> Resume NextLine<BR>NextLine:<BR> On Error Resume Next<BR> <BR> &#039; Rollback Transaction<BR> objOContext.SetAbort<BR> <BR> &#039;Close Recordset and Connection<BR> objRS.Close<BR> Set objRS = Nothing<BR> Set objCommand = Nothing<BR> Set objOContext = Nothing<BR> Set objParam = Nothing<BR> objConn.Close<BR> Set objConn = Nothing<BR> Call Err.Raise(lErrNo, OBJNAME, sErrDesc)<BR> On Error GoTo 0<BR>End Function<BR><BR>SP<BR>**<BR><BR>CREATE PROCEDURE spLogin<BR> @userID varchar,<BR> @Password varchar<BR>AS<BR><BR>select * from login where UserID =@userID and Password =@Password

  2. #2
    Join Date
    Dec 1969

    Default RE: HELP!!!

    don&#039;t you need to Execute smth.?<BR>Set objRS = objCommand.Execute spLogin<BR>also I would try to run your com in vb,just make a class and put on a form 2 texboxes and send them to your class,start F5,then F8<BR>to debug(put your cursor on line you passed to see what is happening)<BR>nth.<BR>

  3. #3
    Charles Guest

    Default RE: HELP!!!

    Thanks,<BR><BR>I fix the problem, it was in my stored procedure, for example, @userID should be declrared as @userID varchar(15) instead of @userID varchar

Posting Permissions

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