Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir i am in just learning phase.
i want to learn connectivity with the data source tool.
just take 2 text box and 2 label name them as user name and password.
take a button name it login.
now create an database in sql.and insert one user name and password.
then again come design part and add data source control.then connect it with sql.
after that i want the coding for login button as if the user enters the correct name and password then it should redirect to another page or else it should message box stating invalid user name and password.
pls sir give this coding......in c#.
thank you sir....
Posted
Comments
TweakBird 23-Jul-11 17:22pm    
P.S: Please try your own created webform (Take Manas answer as reference). please avoid code copying from URL(given in below answer).

I am glad you are learning. That's the whole idea of your assignment, to learn. Anyways, here are some pointers/links which might help you. Good luck.

You might get almost the whole example here, try to understand it and change according to your needs:

http://www.daniweb.com/software-development/csharp/threads/24148[^]

Quite old, but very solid article on CP about data access with .Net. Have a look...

Beginners guide to accessing SQL Server through C#[^]
 
Share this answer
 
Comments
Uday P.Singh 23-Jul-11 13:23pm    
my 5!
Manas Bhardwaj 23-Jul-11 13:41pm    
thanks Uday!
TweakBird 23-Jul-11 17:20pm    
Good answer! My 5!
For connectivity in visual studio
open Server Explorer
right click add Connection
Follow simple steps
After Creating Connection Right click on Database
Click on properties
In Proprties Connection String will be found.
Copy This String.

C#
private void button1_Click(object sender, EventArgs e)
       {
           string cmd="select *from Admin where ID='"+txtFilenO.Text+"' and Password='"+textBox1.Text+"' ";
          SqlConnection con=new SqlConnection();

           con.connectionString="Paste Connection String";
            con.Open();
SqlCommand cmd1 = new SqlCommand(cmd,con);

           SqlDataReader dr = cmd1.ExecuteReader();
           if (dr.Read())
           {
               AdminMenu n = new AdminMenu();
               n.lblsser.Text = dr[0].ToString();
               n.Show();
               this.Dispose();
               this.Close();
               cmd1.Connection.Close();

           }
           else
           {
               cmd1.Connection.Close();
               MessageBox.Show("ID/Password is not valid");
           }

       }


it is connection from wizard,But You should learn meaning of each keyword, So keep l;earning from Google and MSDN.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900