GlobaLevel
asked on
C#.net - datareader issue
not sure...I am getting errors at this line:
sql_username = dataReader["USERNAME"].ToS tring;
sql_username = dataReader["USERNAME"].ToS
try
{
//Dim dl_stores_files As New List(Of String)
//Dim client_stores_files As New List(Of String)
SqlDataReader dataReader = default(SqlDataReader);
int x = 0;
string sqlConnection = null;
using (SqlConnection sqlConn = new SqlConnection())
{
// sqlConnection = "Data Source=xx.xx.xx.xx;Initial Catalog=xx;User Id=;Password=;"
sqlConnection = "Data Source=xx.xx.xx.xx;Initial Catalog=xxx;Trusted_connection=true;";
sqlConn.ConnectionString = sqlConnection;
string SQLstring = "SELECT * FROM customer_login WHERE USERNAME = '" + userName + "' AND PASSWORD = '" + passWord + "'";
// Dim dataReader As SqlDataReader
sqlConn.Open();
using (SqlCommand command = new SqlCommand(SQLstring, sqlConn))
{
dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
if (dataReader.HasRows)
{
while (dataReader.Read())
{
sql_username = dataReader["USERNAME"].ToString;
sql_password = dataReader("PASSWORD").ToString;
TC_id = dataReader("TC_ID").ToString;
Session("email_address") = dataReader("email_address").ToString;
Session("SessionUsername") = sql_username;
Session("sessionPassword") = sql_password;
Session("sessionTC_ID") = TC_id;
Session("MULTI_CLIENT_ID") = dataReader("MULTI_CLIENT_ID").ToString;
}
}
else
{
}
dataReader.Close();
sqlConn.Close();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please note that that is applicable for all fields in the datareader.
Session("key") should be changed as Sessiong["key"] as well.
Session("key") should be changed as Sessiong["key"] as well.
Open in new window