Hi guys just need a little help here. Well I'm done with the code but I can't seem to understand what's wrong with it. I mean when you are done entering your pair of username and password on both forms it's supposed to save the username and password entered on the tabe I made(you should use the same username and password on form1 and form2 when you test my program because I designed it that way), but it won't save the entered username and password on the table I created when you right click and select show table data. My friend told me it's my Visual Studio 2008 that is the problem, not the code because he's done this before and it worked perfectly for him, I just did a remake of his program. so right now I'm asking you guys a favor to go test my program and see if it will save in the table please guys... And if it doesn't work too maybe you can go give me some advice on how I can fix this problem. Thank you very much Daniwebbers. God Bless you all.

Edited 4 Years Ago by king03: short

Hi King03

Maybe this will help, i fixed the code and left you a little video example:

 System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection();
            System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand();
            System.Data.SqlClient.SqlDataAdapter adaptador = new System.Data.SqlClient.SqlDataAdapter();
            DataSet dataset = new DataSet();
            int count;

            try
            {
            connection.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True";
            command.CommandText = "SELECT * FROM [User] WHERE Username='" + textBox1.Text + "' AND Password='" + textBox2.Text + "';";

            connection.Open();

            command.Connection = connection;
            adaptador.SelectCommand = command;
            adaptador.Fill(dataset, "0");          

            count = dataset.Tables[0].Rows.Count;
            }
            catch
            {
                count = 0;
            }

            connection.Close();

                if(count > 0)
                {
                    Form2 form2 = new Form2();
                    form2.Show();
                }
                else
                {
                    connection.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True";
                    command.CommandText = "INSERT INTO [User] (Username, Password) VALUES ('"+ textBox1.Text +"','" + textBox2.Text + "')";

                    connection.Open();

                    command.Connection = connection;
                    command.ExecuteNonQuery();
                    connection.Close();
                    Form3 frm = new Form3();
                    frm.Show();

                }

The video will be live in a few minutes here is the link
http://youtu.be/Cik9_YFTcd4

hey there roemerito, in what form number should I paste this code that you made? thanks by the way.

I used the first form1, then i created a third form form3, to verify that i was adding the information from form1. where u able to see the video?

Edited 4 Years Ago by roemerito

yup just right now, thank you very much, I was able to figure out how to make your link run so I was able to watch it.... thank you and god Bless!

This article has been dead for over six months. Start a new discussion instead.