I have a database(username(key),Fullname,Pass), I want to search for the username and write out the Fullname for this username in a console. I have these:
static DataTable dt = new DataTable();
static SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=""path\login.mdf"";Integrated Security=True");
con.Open();
string username="mate";
SqlDataAdapter sda = new SqlDataAdapter("SELECT Nev FROM Login WHERE username='" + username+ "'", con);
sda.Fill(dt);
string fullname;
if (dt.Rows[0][0].ToString() == "1")then?
"Nev" means Full name
I want it to write the Fullname into the "fullname" string, then just:
Console.Writeline("Welcome {0}",fullname);
Can you help me with this code?
I just don't know how to continue my code. Users can login and register to the app, and when they login i want to greet them like "Hello FullName" when they register their username, fullname and password is stored, and they login with username & pass. I just don't know how to find the Fullname if i know the username. (I'm a beginner in SQL)