string SqlStr; ADODB.Connection Conn1; ADODB.Recordset Rs1; Conn1 = new ADODB.Connection(); Rs1 = new ADODB.Recordset(); Conn1.Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Leo\\Documents\\Visual Studio 2008\\Projects\\CodeDatabase\\CodeDatabase\\CodeDatabase.mdb;Persist Security Info=False;", "", "", 0 ); SqlStr = "SELECT * FROM Codes";
// Open Recordset Rs1.Open (SqlStr, Conn1, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, 0); // Check if anything in the table if (Rs1.EOF == false)
// If so, loop and get all the information to fill the list do { lstSubjects.Items.Add(Rs1.Fields["ID"].Value + "~" + Rs1.Fields["_Subject"].Value); Rs1.MoveNext(); } while (Rs1.EOF == false);
// Call CloseDatabase Conn1.Close(); Conn1 = null; }
|