Milad_ATM
پنج شنبه 25 اسفند 1401, 08:58 صبح
سلام
دوستان من پس از یک مدت طولانی مجددا #c رو با نوشتن یک کد Login شروع کردم و با مشکل مواجه شدم .
using System.Data.SqlClient;
namespace LoginTrain4
{
public partial class Form1 : Form
{
private SqlConnection objconnection = new SqlConnection(@"Data Source=(local);Initial Catalog=TestNo1ForLogin");
private SqlCommand objcommand;
public Form1()
{
InitializeComponent();
}
private void BtnLogin_Click(object sender, EventArgs e)
{
int Var = 0;
try
{
if ((txtUsername.Text == string.Empty) || (txtPassword.Text == string.Empty))
{
MessageBox.Show("Enter Data !");
return;
}
objcommand = new SqlCommand("Select count(*) from table" +
"WHERE UserName=@UserName AND Password=@Password", objconnection);
objcommand.Parameters.AddWithValue("@UserName", txtUsername.Text.ToString());
objcommand.Parameters.AddWithValue("@Password", txtPassword.Text.ToString());
if (objconnection.State==ConnectionState.Closed)
{
objconnection.Open();
Var = (int)objcommand.ExecuteScalar();
}
objconnection.Close();
if (Var > 0 )
{
Form2 frm2 = new Form2();
frm2.Show();
}
else
MessageBox.Show("No Authentication !");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
Var = 0;
objconnection.Close();
}
}
}
}
با نوشتن این کد با این پیغام مواجه شدم :
154584
حدس خودم این هست که مشکل اتصال به Database هست و اون قسمت باید اصلاح بشه!
ممنون میشم از دوستان راهنمایی کنید که با کمک شما شروع دوباره خوبی داشته باشم...
private SqlConnection objconnection = new SqlConnection(@"Data Source=(local);Initial Catalog=TestNo1ForLogin");
private SqlCommand objcommand;
154585
دوستان من پس از یک مدت طولانی مجددا #c رو با نوشتن یک کد Login شروع کردم و با مشکل مواجه شدم .
using System.Data.SqlClient;
namespace LoginTrain4
{
public partial class Form1 : Form
{
private SqlConnection objconnection = new SqlConnection(@"Data Source=(local);Initial Catalog=TestNo1ForLogin");
private SqlCommand objcommand;
public Form1()
{
InitializeComponent();
}
private void BtnLogin_Click(object sender, EventArgs e)
{
int Var = 0;
try
{
if ((txtUsername.Text == string.Empty) || (txtPassword.Text == string.Empty))
{
MessageBox.Show("Enter Data !");
return;
}
objcommand = new SqlCommand("Select count(*) from table" +
"WHERE UserName=@UserName AND Password=@Password", objconnection);
objcommand.Parameters.AddWithValue("@UserName", txtUsername.Text.ToString());
objcommand.Parameters.AddWithValue("@Password", txtPassword.Text.ToString());
if (objconnection.State==ConnectionState.Closed)
{
objconnection.Open();
Var = (int)objcommand.ExecuteScalar();
}
objconnection.Close();
if (Var > 0 )
{
Form2 frm2 = new Form2();
frm2.Show();
}
else
MessageBox.Show("No Authentication !");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
Var = 0;
objconnection.Close();
}
}
}
}
با نوشتن این کد با این پیغام مواجه شدم :
154584
حدس خودم این هست که مشکل اتصال به Database هست و اون قسمت باید اصلاح بشه!
ممنون میشم از دوستان راهنمایی کنید که با کمک شما شروع دوباره خوبی داشته باشم...
private SqlConnection objconnection = new SqlConnection(@"Data Source=(local);Initial Catalog=TestNo1ForLogin");
private SqlCommand objcommand;
154585