ADO.NET을 사용하여 SQL Server에 연결하려고하면 오류가 표시됩니다. ADO.NET 연결 결과 인스턴스 실패
이
코드는 내가 사용하는 것입니다 : 내가해야 할 일을Instance failure.
:
SqlConnection con = new SqlConnection(@"Data Source=.\\SQLEXPRESS;Initial Catalog=abdul;uid=sa;pwd=sqlserver");
SqlCommand cmd = new SqlCommand();
con.Open();
String str="select * from emp where empname='Abdul'";
cmd = new SqlCommand(str, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr == null || !dr.HasRows)
{
MessageBox.Show("No Records found");
}
else
{
while (dr.Read())
{
textBox1.Text = dr[0].ToString();
textBox2.Text = dr[1].ToString();
}
}
는 나는 다음과 같은 오류를 보여줍니다 프로젝트를 실행하고 언제?
가 오류의 스택 트레이스를하시기 바랍니다 복사 할 데이터 소스에서 하나의 백 슬래시를 사용해야 만드는 방법? –
@Alberto Leon : 다음은 System.Data.SqlClient.TdsParser.Connect (ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, 부울 암호화, 부울 trustServerCert, 부울 integratedSecurity, SqlConnection owningObject)의 스택 추적 오류입니다. at System. Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin (ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover (String 모든 것을 넣는 것으로 충분하지 않습니다. –
왜 사용하지 않는가? ConnectionStringBuilder for this : SqlConnection (@ "데이터 원본 =. \\ SQLEXPRESS; 초기 카탈로그 = abdul; uid = sa; pwd = sqlserver"); –