I created a database (without user or password) as a service-based database.
Now I'm trying to insert to a database, but there is a error "Login failed for user"
I have this code:
string J_connetionString1 = null;
SqlConnection J_connection1;
SqlDataAdapter J_adapter1 = new SqlDataAdapter();
string J_sql1 = null;
J_connetionString1 = @"Data Source=.\SQLEXPRESS;Initial Catalog=J_InsData";
J_connection1 = new SqlConnection(J_connetionString1);
J_sql1 = "update instinfo set instinfoNAME = textBox2.text where instinfoID ='1'";
try
{
J_connection1.Open();
J_adapter1.UpdateCommand = J_connection1.CreateCommand();
J_adapter1.UpdateCommand.CommandText = J_sql1;
J_adapter1.UpdateCommand.ExecuteNonQuery();
MessageBox.Show("Row updated !! ");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
i can't comment so i edited the Q.
this error appeared by using this code
error : system.Data.sqlclint.sqlexpection(0x80131904) cannot open database "J_InsData" request by the login. the login faild login failed for user J-PC\J
code: J_connetionString1 = @"Data Source=.\SQLEXPRESS;Initial Catalog=J_InsData;Trusted_Connection=True;Integrated Security=SSPI";
@"Data Source=.\SQLEXPRESS;Initial Catalog=J_InsData;Integrated Security=SSPI";