Sqlexception Error

Joined
Dec 23, 2013
Messages
1
Reaction score
0
Hi everyone, i'm a newbie to C#.NET programming and i need help here. I'm
current doing an application for pocket pc and i get this sqlexception error
when i try to retrieve stuff from the database. My guess is that the error
lies with the connection string. I've tried serveral different connection
string but i still get the error.
SqlConnection con;
public Login()
{
InitializeComponent();
con = new SqlConnection("Data Source=ADMIN-PC\\SQLEXPRESS;Initial Catalog=AMSNEW;Integrated Security=True");
// con = new SqlConnection("Data Source=127.0.0.1.1433;Initial Catalog=AMSNEW;Integrated Security=True;");
}

private void btn_Login_Click(object sender, EventArgs e)
{
con.Close();
con.Open();
string sqlstr = "select Username,Password from tbl_New_UserReg1 where Username='" +txtUsername.Text.Replace("'", "''") + "' Password='" + txtPass.Text.Replace("'", "''") + "'";
SqlCommand cmd = new SqlCommand(sqlstr, con);
SqlDataAdapter Da = new SqlDataAdapter(cmd);
DataTable DT =new DataTable ();
Da.Fill (DT);
//dr = cmd.ExecuteReader();
if (DT.Rows.Count >0)
{
Transaction ts = new Transaction();
ts.Show();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top