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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. equivalent code

equivalent code

Scheduled Pinned Locked Moved C#
csharpquestion
8 Posts 4 Posters 1 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
    V 0
    wrote on last edited by
    #1

    What would be the equivalent in C# for the following? Sub CreateADODB() Dim adoApp As Object adoApp = CreateObject("ADODB.Connection") End Sub Is there a site where you can enter functions of VB and see what the C# (and/or other languages) are? thanks! No hurries, no worries.

    J M 2 Replies Last reply
    0
    • V V 0

      What would be the equivalent in C# for the following? Sub CreateADODB() Dim adoApp As Object adoApp = CreateObject("ADODB.Connection") End Sub Is there a site where you can enter functions of VB and see what the C# (and/or other languages) are? thanks! No hurries, no worries.

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      This is simple and tough to answer - so here goes. Simple: ADODB.COnnection was replaced by OleDbConnection in the System.Data assembly Tough: CreateObject was used in VB and VBScript in create an instance of a COM compatible object. ADODB.Connection was a very commonly used COM Object for connecting to a variet of databases. .NET, and therefore C#, has much interoperability with COM if you did want to look that up and use the, now mostly defunk, ADODB COM libraries.

      V 1 Reply Last reply
      0
      • J J4amieC

        This is simple and tough to answer - so here goes. Simple: ADODB.COnnection was replaced by OleDbConnection in the System.Data assembly Tough: CreateObject was used in VB and VBScript in create an instance of a COM compatible object. ADODB.Connection was a very commonly used COM Object for connecting to a variet of databases. .NET, and therefore C#, has much interoperability with COM if you did want to look that up and use the, now mostly defunk, ADODB COM libraries.

        V Offline
        V Offline
        V 0
        wrote on last edited by
        #3

        actually it was the CreateObject I needed, the ADO stuff was just an example. I need to use a COM object and in VB they've used a CreateObject to call it. I've tried via the tlb and exe file, but I get an errormessage. Now I thought to use the same code they've used in VB, but in C#. thanks a lot! [EDIT]I've found a little exe here in CP, but it isn't wat I need...[/EDIT] No hurries, no worries. -- modified at 8:23 Friday 17th March, 2006

        J 1 Reply Last reply
        0
        • V V 0

          actually it was the CreateObject I needed, the ADO stuff was just an example. I need to use a COM object and in VB they've used a CreateObject to call it. I've tried via the tlb and exe file, but I get an errormessage. Now I thought to use the same code they've used in VB, but in C#. thanks a lot! [EDIT]I've found a little exe here in CP, but it isn't wat I need...[/EDIT] No hurries, no worries. -- modified at 8:23 Friday 17th March, 2006

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          Ah, in which case if you are using Visal Studio, just add a COM reference to the project (right click references>Add reference>COM Tab>Browse) and VS will do the rest for you, allowing you to call the COM object as if it were a .NET class. Visual Studio just does some boiler-plating for you. eg, if I did this with ADODB.COnnection I could go ADODB.ConnectionClass myConn = new ADODB.ConnectionClass(); note it adds the suffix "Class" to the COM Object's true name.

          V 1 Reply Last reply
          0
          • J J4amieC

            Ah, in which case if you are using Visal Studio, just add a COM reference to the project (right click references>Add reference>COM Tab>Browse) and VS will do the rest for you, allowing you to call the COM object as if it were a .NET class. Visual Studio just does some boiler-plating for you. eg, if I did this with ADODB.COnnection I could go ADODB.ConnectionClass myConn = new ADODB.ConnectionClass(); note it adds the suffix "Class" to the COM Object's true name.

            V Offline
            V Offline
            V 0
            wrote on last edited by
            #5

            Actually I've tried to import the dll and the tlb file, but I got an error message, BUT I did find a solution: Import the Microsoft.VisualBasic Object (yes, I know :sigh:) and use the following (example) object idisp; try{ idisp = Interaction.CreateObject("idisp.Command", null); bidisp = true; } catch(Exception e){ bidisp = false; MessageBox.Show(e + ""); } And it worked :-D. I'm not sure if there is a complete C# solution. tnx for the effort!! No hurries, no worries.

            G 1 Reply Last reply
            0
            • V V 0

              What would be the equivalent in C# for the following? Sub CreateADODB() Dim adoApp As Object adoApp = CreateObject("ADODB.Connection") End Sub Is there a site where you can enter functions of VB and see what the C# (and/or other languages) are? thanks! No hurries, no worries.

              M Offline
              M Offline
              mcljava
              wrote on last edited by
              #6

              Try the SQL/ADO forum for more info. BUT here's what I have done: ODBC - Easy to do in C#, there are tons of article here. Worst part is the DSN as you eithe rhave to manually provision it OR use on of the autmation techniques you find on CodeProject - and trust me when I say there are a few. You can use this with MySQL, or other non Microsoft DBs as opposed to delving into the C based APIs. If your app is running on say Linux this might be a good option. OLE DB - Not really for your relational databases per se, but if you have data stores like Excel or other spreadsheets, or office files, it works great and again pretty easily once you know the finer configuration points. SQLClient - If you are using SQL Server then this is probably the best route because of the inherent support. All of the options Odbc, OleDb, and SqlClient have a similar data model. You should be able to find code here, of course on MSDN, and throughout other sites. Good luck Mike Luster CTI/IVR/Telephony SME

              V 1 Reply Last reply
              0
              • M mcljava

                Try the SQL/ADO forum for more info. BUT here's what I have done: ODBC - Easy to do in C#, there are tons of article here. Worst part is the DSN as you eithe rhave to manually provision it OR use on of the autmation techniques you find on CodeProject - and trust me when I say there are a few. You can use this with MySQL, or other non Microsoft DBs as opposed to delving into the C based APIs. If your app is running on say Linux this might be a good option. OLE DB - Not really for your relational databases per se, but if you have data stores like Excel or other spreadsheets, or office files, it works great and again pretty easily once you know the finer configuration points. SQLClient - If you are using SQL Server then this is probably the best route because of the inherent support. All of the options Odbc, OleDb, and SqlClient have a similar data model. You should be able to find code here, of course on MSDN, and throughout other sites. Good luck Mike Luster CTI/IVR/Telephony SME

                V Offline
                V Offline
                V 0
                wrote on last edited by
                #7

                tnx but I'm not going to the db, it was the CreateObject I needed and so far I was succesful :-) (see complete thread) tnx! No hurries, no worries.

                1 Reply Last reply
                0
                • V V 0

                  Actually I've tried to import the dll and the tlb file, but I got an error message, BUT I did find a solution: Import the Microsoft.VisualBasic Object (yes, I know :sigh:) and use the following (example) object idisp; try{ idisp = Interaction.CreateObject("idisp.Command", null); bidisp = true; } catch(Exception e){ bidisp = false; MessageBox.Show(e + ""); } And it worked :-D. I'm not sure if there is a complete C# solution. tnx for the effort!! No hurries, no worries.

                  G Offline
                  G Offline
                  Guffa
                  wrote on last edited by
                  #8

                  I examined the CreateObject class, and doing the same without it is not so hard: object idisp; bool bidisp; try { idisp = Activator.CreateInstance(Type.GetTypeFromProgID("idisp.Command")); bidisp = true; } catch (Exception e) { bidisp = false; MessageBox.Show(e + ""); } --- b { font-weight: normal; }

                  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