이 오류를 수정하는 방법을 알려주시겠습니까?Access 데이터베이스에서 데이터를 목록 상자로 읽어들입니다.
SqlCommand cmd = new SqlCommand(sqlCmd, conn)
--> conn: Aurgument type 'System.Data.OleDb.OleDbConnection' is not assignable to parameter type 'System.Data.SqlClient.SqlConnection'.
private void Form1_Load(object sender, EventArgs e)
{
string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=C:\\Users\\KevinDW\\Desktop\\dotNET\\Week 5\\Prak1\\demo1.accdb";
OleDbConnection conn = new OleDbConnection(connString);
conn.Open();
string sqlCmd = "SELECT CursusNaam FROM tblCursus";
SqlCommand cmd = new SqlCommand(sqlCmd, conn);
using (SqlDataReader reader = cmd.ExecuteReader())
{
listBox1.Items.Add(reader);
}
conn.Close();
}
}
변경하는 SqlCommand : 연결 문자열을 읽고 ... 분명히하지, 그래서
SqlConnection
대신편집을 사용합니다. –
OleDebConnection과 함께 사용할 OleCommand 및 OleDataReader –