views:

81

answers:

3

I have this, and i've been fiddling around with it for a while but i'm completely stuck. can anyone help me make a little sense of this. i'm trying to rewrite this into .NET. thanks.

Set objCmd = Server.CreateObject("ADODB.Command")
 Set objRS = Server.CreateObject("ADODB.Recordset")
 objCmd.ActiveConnection = Application("ConnString")
 With objCmd
  .CommandText = "sp_CheckUserLogin"
  .CommandType = adCmdStoredProc
  objCmd(1) = strUserName
  Set objRS = .Execute 
 End With
 Set objCmd = Nothing

 If objRS.EOF Then
  strErrString = strErrString & "Invalid Account Information.<br>"
  Call InsertLoginHistory(strUserName, Trim(Request.Form("Password")), Request.ServerVariables("REMOTE_HOST"), "User Not Found")
  bLoggedIn = False
 Else
  iUserNumber = objRS("USER_NUMBER")
  strPassword = Trim(objRS("USER_PASSWORD"))
  strIPBand =  Trim(objRS("IP_BAND"))
  iFailedCount =  objRS("FAILED_LOGIN_CNT")
  dLastFailedLogin =  objRS("LAST_FAILED_LOGIN")
  strLoggedInStatus =  objRS("LOGGED_IN_STATUS")
  strLockUser =  objRS("LOCKUSER")
            ....
A: 

objRS is a RecordSet. Here are some tips for VB6 ADO. Here is a tutorial to get you familiar with ADO.NET (the .NET equiv of VB6's ADO).

Dinah
+1  A: 

Assuming you're connecting to MS Sql Server, use SqlCommand, SqlConnection and Dataset/DataTable classes. ADO.Net isn't too hard to understand if you know ADO.

Sidharth Panwar
+3  A: 

Something along these lines should get you going in the right direction. You will need to add a reference for System.Configuration

using System.Data.SqlClient
using System.Configuration

SqlConnection sqlConn = null;
SqlCommand sqlCmd = null;
SqlDataReader sqlRdr = null;

try
{
    // get connection string from web.config or app.config
    sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["SomeConnectionString"].ConnectionString);
    sqlConn.Open();

    sqlCmd = new SqlCommand("sp_CheckUserLogin", sqlConn);
    sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
    // define parameters like this
    sqlCmd.Parameters.Add(new SqlParameter("@user", strUserName));
    sqlRdr = sqlCmd.ExecuteReader();
    while (sqlRdr.Read())
    {
        // get values by column name or index
        strPassword = sqlRdr["USER_NUMBER"].ToString();
    }
catch(Exception ex)
{
    // do your error handling here
}
finally
{
    // close connections
     if (sqlConn != null)
        sqlConn.Close();
     if (sqlRdr != null)
        sqlRdr.Close();
}