Re: New to C# - DB question
- From: "heddy" <hedbonker@xxxxxxxxx>
- Date: 18 Aug 2006 13:23:50 -0700
As for the security concern, I switched the login to use SQL Server
auth like this:
private void btnSubmit_Click(object sender, EventArgs e)
{
if (this.txtPassWd.Text.Length < 1 ||
this.txtUserID.Text.Length < 1)
{
MessageBox.Show("You MUST fill both fields in!");
return;
}
SqlConnection Conn;
SqlDataReader reader = null;
Conn = new SqlConnection("user id=" + this.txtUserID.Text +
";" +
"password=" +
this.txtPassWd.Text + ";" +
"server=MIKIE\\SQLEXPRESS;" +
"database=Media Manager;" +
"connection timeout=30");
try
{
Conn.Open();
}
catch
{
MessageBox.Show("Login Failed for user: " +
this.txtUserID.Text);
return;
}
try
{
SqlCommand cmd = new SqlCommand("spGetAuthority",
Conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@UserName",
this.txtUserID.Text));
reader = cmd.ExecuteReader();
if (reader.HasRows)
{
// Login is good here
reader.Read();
oLocalUser.iAuthority = reader.GetInt32(0);
oLocalUser.bLoggedIn = true;
MessageBox.Show("Login is good for User: " +
this.txtUserID.Text + " Auth code = " +
oLocalUser.iAuthority.ToString());
}
else
{
MessageBox.Show("Login Failed");
}
}
finally
{
reader.Close();
Conn.Close();
}
}
.
- Follow-Ups:
- Re: New to C# - DB question
- From: heddy
- Re: New to C# - DB question
- References:
- New to C# - DB question
- From: hedbonker
- Re: New to C# - DB question
- From: Steven Nagy
- Re: New to C# - DB question
- From: heddy
- Re: New to C# - DB question
- From: Marc Gravell
- Re: New to C# - DB question
- From: heddy
- Re: New to C# - DB question
- From: heddy
- New to C# - DB question
- Prev by Date: Re: Free Reports
- Next by Date: Re: Datagridview: Copy row to array
- Previous by thread: Re: New to C# - DB question
- Next by thread: Re: New to C# - DB question
- Index(es):
Relevant Pages
|