Could anyone point me into the right direction on how to make a C# SQL Datalogin?
GAME
-5
Junior Poster
Recommended Answers
Jump to Postusing System.Data.SqlClient; SqlConnection conn=new Sqlconnection("YourConnectionString"); conn.Open(); string qry="SELECT * FROM Tablename"; Sqlcommand cmd=new SqlCommand(qry,conn); bool userFound=false; SqlDatareader dr; dr=cmd.ExecuteReader(); while(dr.Read()) { if(user==user.Text&&pass=pass.Text) { userFound=true; break; } } if(userFound) { //Do Something e.g Response.Redirect("ToSomePage.aspx"); } else { }
Jump to PostCode above is very unsafe and has many possibilities to fail. Better to use try/catch/finally block for connection to the database and use a more "Where statement query"
using System.Data.SqlClient; private void btnCompile_Click(object sender, EventArgs e) { string qry = "SELECT Password FROM Tablename WHERE User=" + …
Jump to PostThat has to be a remote db. So everyone can access it. Some info.
Jump to PostWhat do you mean? A method in Win form to insert userName, password and an email to sql dataBase?
YOu have to pass the data from textBoxes to sql command parameters, end execute the procedure.
Try this code:private void InsertingData() { string connString = @"server=x;uid=y;pwd=z;database=xyz"; //this …
All 17 Replies
mcriscolo
47
Posting Whiz in Training
edgias
0
Newbie Poster
Singlem
0
Light Poster
jugosoft
25
Junior Poster in Training
Singlem
0
Light Poster
Mitja Bonca
557
Nearly a Posting Maven
GAME
-5
Junior Poster
Mitja Bonca
557
Nearly a Posting Maven
GAME
-5
Junior Poster
Singlem
0
Light Poster
GAME
-5
Junior Poster
Singlem
0
Light Poster
shajis001
-1
Newbie Poster
shajis001
-1
Newbie Poster
GAME
-5
Junior Poster
Mitja Bonca
557
Nearly a Posting Maven
GAME
commented:
Sweet, It worked...
+0
GAME
-5
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.