Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to retrieve records from a ADODB with c#

How to retrieve records from a ADODB with c#

Scheduled Pinned Locked Moved Database
databasecsharpsysadmintutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VanEtienne
    wrote on last edited by
    #1

    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;

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups