M
mo.
I need some help in accessing Jet database using DAO.
I have just started to learn c# and am trying to rewrite a program I
have in vb.net to c#. In VB.Net I can do this:
Dim ws As DAO.Workspace
Dim db As DAO.Database
ws = DAODBEngine_definst.Workspaces(0)
db = ws.OpenDatabase(DBFileName)
Dim rs As DAO.Recordset
Dim temp As Integer
rs = db.OpenRecordset("select * from Folder where FolderNo=0")
My converted code in c# is:
DAO._DBEngine dbEng = new DAO.DBEngineClass();
DAO.Workspace ws = dbEng.CreateWorkspace("", "admin", "",
DAO.WorkspaceTypeEnum.dbUseJet);
DAO.Database db = ws.OpenDatabase(DBFileName, false, false, "");
DAO.Recordset rs;
rs = db.OpenRecordset("select * from Folder where FolderNo=0", "", ""
,"");
The additional parameters in OpenDatabase and OpenRecordset in vb.net
are optional but in c# they are mandatory. I have tried various
combinations, using null, DAO.RecordsetTypeEnum, etc. but I always get
an error at the OpenRecordset line: "Operation is not supported for
this type of object".
I have tried searching the c# Google group plus other groups but have
not found a solution. Does anyone know the proper parameters I should
put in for both OpenDatabase and OpenRecordset in c#?
I have just started to learn c# and am trying to rewrite a program I
have in vb.net to c#. In VB.Net I can do this:
Dim ws As DAO.Workspace
Dim db As DAO.Database
ws = DAODBEngine_definst.Workspaces(0)
db = ws.OpenDatabase(DBFileName)
Dim rs As DAO.Recordset
Dim temp As Integer
rs = db.OpenRecordset("select * from Folder where FolderNo=0")
My converted code in c# is:
DAO._DBEngine dbEng = new DAO.DBEngineClass();
DAO.Workspace ws = dbEng.CreateWorkspace("", "admin", "",
DAO.WorkspaceTypeEnum.dbUseJet);
DAO.Database db = ws.OpenDatabase(DBFileName, false, false, "");
DAO.Recordset rs;
rs = db.OpenRecordset("select * from Folder where FolderNo=0", "", ""
,"");
The additional parameters in OpenDatabase and OpenRecordset in vb.net
are optional but in c# they are mandatory. I have tried various
combinations, using null, DAO.RecordsetTypeEnum, etc. but I always get
an error at the OpenRecordset line: "Operation is not supported for
this type of object".
I have tried searching the c# Google group plus other groups but have
not found a solution. Does anyone know the proper parameters I should
put in for both OpenDatabase and OpenRecordset in c#?