How to retrieve records from a ADODB with c#
-
I can connect to it and get the column names, etc. But it doesn't retrieve any records and I don't know why! I have tried a few different ways, but nothing seems to work. What am I doing wrong?? Here's my code: // string query = @"SELECT * FROM CONNTEST\FLOW_1"; string DBConnection = @"Provider=WinCCOLEDBProvider.1;DataSource=Laptop\WinCC;Catalog=CC_Connecti_06_07_29_15_50_04R;"; string SqlStr = @"TAG:R,'CONNTEST\FLOW_1','0000-00-00 00:10:00.000','0000-00-00'"; //string SqlStr = @"TAG:R,'CONNTEST\FLOW_1','0000-00-00 00:30:00.000','0000-00-00 00:00:00.000'"; // TAG:R,'CONNTEST\FLOW_1','0000-00-00 00:30:00.000','0000-00-00 00:00:00.000' //string SqlStr = "TAG:R,1,'0000-00-00 00:30:00.000','0000-00-00 00:00:00.000'"; //Open Recordset via Connection object. //string SqlStr = @"TAG:R,'CONNTEST\FLOW_1','0000-00-00 00:01:00','0000-00-00 00:00:00"; // 1: Make Connection to Database ADODB.ConnectionClass Conn = new ADODB.ConnectionClass(); Conn.ConnectionString = DBConnection; Conn.CursorLocation = CursorLocationEnum.adUseServer; Conn.Open(DBConnection, "", "", 0); // Conn = Server.CreateObject("ADODB.Connection"); // 2: Use the command text query ADODB.CommandClass OCom = new ADODB.CommandClass (); OCom.CommandType = ADODB.CommandTypeEnum.adCmdText; OCom.ActiveConnection = Conn; OCom.CommandText = SqlStr; // 3: Create the RecordSet and fill with the data //'ADODB.RecordsetClass rs = new ADODB.RecordsetClass(); //rs.Open(SqlStr,DBConnection,ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1); //'rs.Open(OCom, Type.Missing, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic, -1); object dummy = Type.Missing; ADODB.Recordset rs = OCom.Execute(out dummy, ref dummy, 0); object GetName; GetName = rs.RecordCount; ////////GetName = rs.Fields[1].Value;