현재 데이터베이스에 정보를 저장하는 코드를 작성하고 있습니다. 나는 그것이 작동하도록 마지막 장애물에 접근하고 있다고 생각한다.데이터베이스를 열지 못했습니다 - 사용자가 로그인하지 못했습니다.
내 문제는 저장을 클릭하면 로그인으로 요청 된 데이터베이스 [데이터베이스 파일 경로]를 열 수 없다는 메시지 상자가 나타납니다. 로그인에 실패했습니다. 'User-PC \ User'에 대한 로그인에 실패했습니다.
그러나 나중에 데이터베이스에 대한 로그인 세부 정보를 만들지 않았으므로 프로그램을 사용하는 사람이 정보를 기록 할 수 있기를 바랍니다.
나는이 문제를 해결하기 위해 어디를보아야하는지 잘 모르겠지만, 현재 SSMS를 다운로드하여 거기서 고칠 수 있는지 확인하고 싶습니다.
도움이 될 것입니다. 감사합니다. 내 코드는
,
문자열 constring = "데이터 원본 = (LocalDB) \ MSSQLLocalDB; 초기 카탈로그 = C : \ 사용자 \ 사용자 \ 문서 프로젝트 \ 비주얼 스튜디오 2015 \ \ LossApplication \ LossApplication \ LossDB.mdf ; 통합 보안 = 예; Trusted_Connection = True; ";
문자열 쿼리 = "LossDB.LossTable (손실, 장비, 이벤트, 책임 성, 시작) 값 (@lossid, @equipment, @Cause, @reason, @start)에 삽입;"; Integrated Security
는 SQL 서버의 Windows 인증 모드를 의미합니다 사용
SqlConnection conLossDB = new SqlConnection(constring);
SqlCommand cmdLossDB = new SqlCommand(query, conLossDB);
cmdLossDB.Parameters.AddWithValue("@lossid", textBox1.Text);
cmdLossDB.Parameters.AddWithValue("@Equipment", comboBox1.Text);
cmdLossDB.Parameters.AddWithValue("@Cause", comboBox2.Text);
cmdLossDB.Parameters.AddWithValue("@Reason", comboBox3.Text);
cmdLossDB.Parameters.AddWithValue("@start", dateTimePicker1.Text);
//Defines which boxes to read in order to input the text from the defined boxes into the corresponding columns
SqlDataReader myReader;
try
{
conLossDB.Open();
myReader = cmdLossDB.ExecuteReader();
MessageBox.Show("Loss Entry Saved");
//Opens the database and carries out the defined command outlined in the code above
while (myReader.Read())
{
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
과 같이 표시되며 'Integrated Security = True'로 변경하십시오. 또는 '통합 보안 = SSPI'. – Venky
나는 둘 다 시도하고 두 번 같은 오류 상자가 나타납니다 ... – Loplac92
DB에 대한 사용 권한은 무엇입니까? 서버에 어떤 로그인이 있고 데이터베이스에 대한 로그인의 액세스 수준은 어느 정도입니까? "Everyone"이 응용 프로그램을 통해 데이터베이스에 쓸 수있게하려면 응용 프로그램이 인증에 사용할 SQL 계정을 설정 한 다음 현재 사용자의 정보를 db 자체에 저장하는 것이 좋습니다 감사 추적)을 사용하여 db에 직접 인증하지 마십시오. – mikey