سلام.من دستور زير رو مي نويسم تو برنامم كه با C# و sqlهستش.
string conStr = "Data Source=.\\sqlexpress;Initial Catalog=5;Integrated Security=True ";
SqlConnection con = new SqlConnection();
con.ConnectionString = conStr;
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.Text;
com.CommandText = "insert into Table_1 (name)values(@name)";
com.Parameters.AddWithValue("@name", txtName.Text);
con.Open();
com.ExecuteNonQuery();
con.Close();
برنامه اجرا مي شه و خطايي نمي گيره اما وقتي توي فرمم يه داده وارد مي كنم و مي خوام اون رو ثبت كنم خطاي زير رو ميده:
sqlEexception was unhandeleld
Cannot open database "5" requested by the login. The login failed.
Login failed for user m
مشكل كار از كجاست؟ راهنمايي كنيد ممنون ميشم.
string conStr = "Data Source=.\\sqlexpress;Initial Catalog=5;Integrated Security=True ";
SqlConnection con = new SqlConnection();
con.ConnectionString = conStr;
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.Text;
com.CommandText = "insert into Table_1 (name)values(@name)";
com.Parameters.AddWithValue("@name", txtName.Text);
con.Open();
com.ExecuteNonQuery();
con.Close();
برنامه اجرا مي شه و خطايي نمي گيره اما وقتي توي فرمم يه داده وارد مي كنم و مي خوام اون رو ثبت كنم خطاي زير رو ميده:
sqlEexception was unhandeleld
Cannot open database "5" requested by the login. The login failed.
Login failed for user m
مشكل كار از كجاست؟ راهنمايي كنيد ممنون ميشم.
