Sagar S Sagar S - 1 year ago 41
SQL Question

Can't fetch data from Sql database for registartion form n login form

private void button1_Click(object sender, EventArgs e)
SqlConnection con = new SqlConnection("Data Source=DESKTOP-O72COGQ;Initial Catalog=ClinicManagementtest;Integrated Security=True");

SqlCommand sc = new SqlCommand("select Name ,Password from Registartion_form WHERE Name='" + textBox1.Text + "'and Password='" + textBox2.Text + "'", con);
SqlDataAdapter da = new SqlDataAdapter(sc );
DataTable dt = new DataTable();

if (dt.Rows.Count > 0)
MessageBox.Show("Login Success");
MessageBox.Show("Incorrect login");

Answer Source

it says invalid object name. meaning the table you're trying to use in your sql query is not accessible by your code. can you make sure the table Registartion_form exists in the database you're connecting to?

also note, that you have written Registartion not Registration. notice the typing error "ar" instead of "ra"?

maybe that could be the cause of error. if in your sql server it's Registration and not Registartion.