SqlDataAdapter returns empty even though there is correct data in the DataBase.

I am new to c# web DB programing . I have tried to write a registration form .
Here the DB connection part:
The remarks part are my tries to make it work (which did not) .
The problem is that dt stays empty even though there is corrrect data in loginTable table.
Wouls you help me understand and solve the problem?

private void loginBotton_Click(object sender, EventArgs e)
{

        // Integrated Security = true;
       //  User Instance = true;

        // sp_configure 'user instances enabled','1';



        SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\SARAH\Documents\loginData.mdf;Integrated Security=True;Connect Timeout=30");
      
       //  SqlDataAdapter sda = new SqlDataAdapter( "select count(*) from loginTable where userName=' "+ userNameTextBox.Text + "' and passwrd ='"+ passwrdTextBox.Text+"'", con );
        SqlDataAdapter sda = new SqlDataAdapter("select ( * ) from loginTable", con);
        DataTable dt = new DataTable();

        sda.Fill(dt);

        if (dt.Rows[0][0].ToString() == "1")
        {
            this.Hide();
            mainLoginform mlf = new mainLoginform();
            mlf.Show();
        }
        else
        {
            MessageBox.Show(" Please check your user name and password");
        }
    }
0
edit delete
are you sure?
asked yasmin amran

0 answers

Post an answer but please log in first

Post Answer
  1. Please log in to post answer

Similar Questions

Tagsfor this question

Forumall questions