0% found this document useful (0 votes)
2 views4 pages

Connection String

The document contains C# code for a SQL database connection and user interface functionalities, including user registration, login verification, data update, and deletion. It also includes timer functionality for progress indication and methods for displaying data in a DataGridView. Additionally, it handles password visibility and search criteria for products in the database.

Uploaded by

kurmibikesh52
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Connection String

The document contains C# code for a SQL database connection and user interface functionalities, including user registration, login verification, data update, and deletion. It also includes timer functionality for progress indication and methods for displaying data in a DataGridView. Additionally, it handles password visibility and search criteria for products in the database.

Uploaded by

kurmibikesh52
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Connection String:

SqlConnection con = new SqlConnection("Data Source=DESKTOP-LCTKQVU\\


SQLEXPRESS;Integrated Security=True;");

[Link] Code:
private void timer1_Tick(object sender, EventArgs e)
{
[Link](2);
[Link] = [Link]() + " % ";
if ([Link] > 99)
{
[Link] = false;
LoginForm f2 = new LoginForm();
[Link]();
[Link]();
}
}

2. Timer Enable code for further Process:


private void button2_Click(object sender, EventArgs e)
{
[Link] = true;
}
3. New Account Registration Code:
{
[Link]();
string username, password;
username = [Link];
password = [Link];
SqlCommand cmd = new SqlCommand("insert into login_tbl
values(@username,@password)", con);
[Link]("@username", [Link]);
[Link]("@password", [Link]);
[Link]();

[Link]();
[Link]("you are registered successfully");
}
[Link] verification from Data table:
if ([Link] == "")
{
[Link]("please enter your username");
[Link]();
[Link]();

}
else if ([Link] == "")
{
[Link]("provide password for login");
[Link]();
[Link]();
}
else
{
[Link]();
string username, password;
username = [Link];
password = [Link];
try
{
string querry = "select * from login_tbl where username='" + [Link] + "' and
password='" + [Link] + "'";
SqlDataAdapter sda = new SqlDataAdapter(querry, con);
DataTable dt = new DataTable();
[Link](dt);
if ([Link] > 0)
{

username = [Link];
password = [Link];
Mainform mf = new Mainform();
[Link]();
}
else
{
[Link]("invalid login details", "error", [Link],
[Link]);
}
}
catch
{
[Link]("invalid login");
}
finally
{
[Link]();
}

}
}

[Link] Table:
private void button5_Click(object sender, EventArgs e)
{
[Link]();
string username, password;
username = [Link];
password = [Link];
SqlCommand cmd= new SqlCommand("update login_tbl set username=@username,
password=@password where username=@username ",con);
[Link]("@username", [Link]);
[Link]("@password", [Link]);
[Link]();

[Link]();
[Link](" data is updated successfully");
}
[Link] show:
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if ([Link] == true)
[Link] = false;
else
[Link] = true;

}
[Link] Down :
private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
if ([Link] == [Link])
[Link]();
}
[Link] GridView:
private void button4_Click(object sender, EventArgs e)
{
[Link]();
String id, pruductname, purchasedate, manufacturedate, expiredate, quantity, quality,
perunitprize, category;
id = [Link];
pruductname = [Link];
purchasedate = [Link];
manufacturedate = [Link];
expiredate = [Link];
quantity = [Link];
perunitprize = [Link];
quality = [Link];
category = [Link];
SqlCommand cmd1 = new SqlCommand("select * from Product", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd1);
DataTable dt = new DataTable();
[Link](dt);
[Link] = dt;
[Link]();
[Link]();
}
[Link] Data From Table:
private void button2_Click(object sender, EventArgs e)
{
[Link]();
String id, productname, purchasedate, manufacturedate, expiredate, quantity, quality,
perunitprize, category;
id = [Link];
productname = [Link];
purchasedate = [Link];
manufacturedate = [Link];
expiredate = [Link];
quantity = [Link];
perunitprize = [Link];
quality = [Link];
category = [Link];
SqlCommand cmd = new SqlCommand("delete Product where id=@id", con);
[Link]("@id", [Link]);
[Link]("@productname", [Link]);
[Link]("@purchasedate", [Link]);
[Link]("@manufacturedate", [Link]);
[Link]("@expiredate", [Link]);
[Link]("@quantity", [Link]);
[Link]("@perunitprize", [Link]);
[Link]("@quality", [Link]);
[Link]("@category", [Link]);
[Link]();
SqlCommand cmd1 = new SqlCommand("select * from Product", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd1);
DataTable dt = new DataTable();
[Link](dt);
[Link] = dt;
[Link]();
[Link]();
[Link]("data deleted successfully");
}
10. Search Criteria:
private void button5_Click(object sender, EventArgs e)
{
[Link]();
String id, pruductname, purchasedate, manufacturedate, expiredate, quantity, quality,
perunitprize, category;
id = [Link];
pruductname = [Link];
purchasedate = [Link];
manufacturedate = [Link];
expiredate = [Link];
quantity = [Link];
perunitprize = [Link];
quality = [Link];
category = [Link];
SqlCommand cmd1 = new SqlCommand("select * from Product where
id='"+[Link]+"' or productname='"+[Link]+"' or category='"+[Link]+"'
or quality='"+[Link]+"'", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd1);
DataTable dt = new DataTable();
[Link](dt);
[Link] = dt;
[Link]();
[Link]();
}

You might also like