sql error: cannot open database
hi... i m getting error like this in my code
public partial class items : Form
{
string con = "Server=.\\SQLEXPRESS;Database=|DataDirectory|/db1.mdf;Trusted_Connection=True;";
SqlDataAdapter da = new SqlDataAdapter();
SqlConnection objconnection;
private void btnshow_Click(object sender, EventArgs e)
{
objconnection = new SqlConnection(con);
objconnection.Open(); <-------ERROR
string ss=comboBox1.SelectedValue.ToString();
string q = "select * from items where cname= " + "'" + ss.ToString() + "'";
SqlCommand comm = new SqlCommand("select * from items where cname=@cname", objconnection);
comm.Parameters.AddWithValue("@cname", ss.ToString());
comm.ExecuteNonQuery();
textBox1.Text = comboBox1.SelectedValue.ToString();
da = new SqlDataAdapter(q, con);
DataSet ds = new DataSet();
da.Fill(ds);
dataGrid1.DataSource = ds.Tables[0];
}
Error
Cannot open database "|DataDirectory|/db1.mdf" requested by the login. The login failed.
Login failed for user 'AHUJA-2FD08D31D\Ahuja's'.