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. General Programming
  3. C#
  4. SQL anyone ?

SQL anyone ?

Scheduled Pinned Locked Moved C#
questioncsharpc++databasesql-server
9 Posts 5 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.
  • F Offline
    F Offline
    Frank Olorin Rizzi
    wrote on last edited by
    #1

    So, ehr... ..hope you won't think that this question is in the wrong forum, but.. You remember all the good'ol'SQL APIs like SQLConnect, SQLFetch, ... ? How can I access those from a C# app? I've tried to use the System.Data.SqlClient namespace stuff, but that is targetted for SQL Server DBs, and I am just trying to do something more ODBC-oriented (i.e. that would work with other DBMS as well). To be specific: I really, really, **really** need to execute an SQL call (rather than using Data Sets, and such). Is it possible in C#, or should I just go back to C++ ? Suggestions anyone? Thanks in advance, F.O.R.

    R A D F 4 Replies Last reply
    0
    • F Frank Olorin Rizzi

      So, ehr... ..hope you won't think that this question is in the wrong forum, but.. You remember all the good'ol'SQL APIs like SQLConnect, SQLFetch, ... ? How can I access those from a C# app? I've tried to use the System.Data.SqlClient namespace stuff, but that is targetted for SQL Server DBs, and I am just trying to do something more ODBC-oriented (i.e. that would work with other DBMS as well). To be specific: I really, really, **really** need to execute an SQL call (rather than using Data Sets, and such). Is it possible in C#, or should I just go back to C++ ? Suggestions anyone? Thanks in advance, F.O.R.

      R Offline
      R Offline
      Rob Graham
      wrote on last edited by
      #2

      1. System.Data.OleDbClient 2. SqlConnection,SqlCommand and OleDbConnection,OleDbCommand can execute SQL statements. You can use an OleDbDataReader (SQlDataReader if MSSQL) to retun records in a fast forwar-only cursor and do as you wish with the data. xxxCommand and xxxConnection can also execute quries that have no return data or onlay a single scalar value. Genius may have its limitations, but stupidity is not thus handicapped. - Elbert Hubbard

      F 1 Reply Last reply
      0
      • F Frank Olorin Rizzi

        So, ehr... ..hope you won't think that this question is in the wrong forum, but.. You remember all the good'ol'SQL APIs like SQLConnect, SQLFetch, ... ? How can I access those from a C# app? I've tried to use the System.Data.SqlClient namespace stuff, but that is targetted for SQL Server DBs, and I am just trying to do something more ODBC-oriented (i.e. that would work with other DBMS as well). To be specific: I really, really, **really** need to execute an SQL call (rather than using Data Sets, and such). Is it possible in C#, or should I just go back to C++ ? Suggestions anyone? Thanks in advance, F.O.R.

        A Offline
        A Offline
        Arjan Einbu
        wrote on last edited by
        #3

        Look at the System.Data.Odbc (only in 1.1) and System.Data.OleDb namespaces for setting up connections and executing commands etc. The OdbcCommand and OleDbCommand objects both have the ExecuteNonQuery method (and more) to execute SQL statements without involving DataSet and DataTable objects...

        F 1 Reply Last reply
        0
        • F Frank Olorin Rizzi

          So, ehr... ..hope you won't think that this question is in the wrong forum, but.. You remember all the good'ol'SQL APIs like SQLConnect, SQLFetch, ... ? How can I access those from a C# app? I've tried to use the System.Data.SqlClient namespace stuff, but that is targetted for SQL Server DBs, and I am just trying to do something more ODBC-oriented (i.e. that would work with other DBMS as well). To be specific: I really, really, **really** need to execute an SQL call (rather than using Data Sets, and such). Is it possible in C#, or should I just go back to C++ ? Suggestions anyone? Thanks in advance, F.O.R.

          D Offline
          D Offline
          Daniel Turini
          wrote on last edited by
          #4

          While the previous answers were complete and technically correct, why do I still have the feeling you are using the wrong tool for the job? You can do it on anything you choose - from .bat to .net - A customer

          F 1 Reply Last reply
          0
          • R Rob Graham

            1. System.Data.OleDbClient 2. SqlConnection,SqlCommand and OleDbConnection,OleDbCommand can execute SQL statements. You can use an OleDbDataReader (SQlDataReader if MSSQL) to retun records in a fast forwar-only cursor and do as you wish with the data. xxxCommand and xxxConnection can also execute quries that have no return data or onlay a single scalar value. Genius may have its limitations, but stupidity is not thus handicapped. - Elbert Hubbard

            F Offline
            F Offline
            Frank Olorin Rizzi
            wrote on last edited by
            #5

            Thanks Rob, but that's not exactly what I was looking for. I suspect I'll end up moving to C++ one way or the other :-) Thanks again, F.O.R.

            1 Reply Last reply
            0
            • A Arjan Einbu

              Look at the System.Data.Odbc (only in 1.1) and System.Data.OleDb namespaces for setting up connections and executing commands etc. The OdbcCommand and OleDbCommand objects both have the ExecuteNonQuery method (and more) to execute SQL statements without involving DataSet and DataTable objects...

              F Offline
              F Offline
              Frank Olorin Rizzi
              wrote on last edited by
              #6

              Hmmm... ..I didn't know that 1.1 had an Odbc namespace! I'll take a look, thanks :-) F.O.R.

              1 Reply Last reply
              0
              • D Daniel Turini

                While the previous answers were complete and technically correct, why do I still have the feeling you are using the wrong tool for the job? You can do it on anything you choose - from .bat to .net - A customer

                F Offline
                F Offline
                Frank Olorin Rizzi
                wrote on last edited by
                #7

                Because indeed I am. I am looking for something that has a 1:1 correspondence to the sql.h library from C/C++. Now, while C# has alternatiuve ways to achieve the same goals (all of the Data namespace, for instance), I am not surprized to find that C# keeps you away from such low level kind of stuff. It indeed makes much more sense for me to use a C++ (managed or not) app in this case, but I figured I could look around for a bit before giving up on being more modern :-) F.O.R.

                1 Reply Last reply
                0
                • F Frank Olorin Rizzi

                  So, ehr... ..hope you won't think that this question is in the wrong forum, but.. You remember all the good'ol'SQL APIs like SQLConnect, SQLFetch, ... ? How can I access those from a C# app? I've tried to use the System.Data.SqlClient namespace stuff, but that is targetted for SQL Server DBs, and I am just trying to do something more ODBC-oriented (i.e. that would work with other DBMS as well). To be specific: I really, really, **really** need to execute an SQL call (rather than using Data Sets, and such). Is it possible in C#, or should I just go back to C++ ? Suggestions anyone? Thanks in advance, F.O.R.

                  F Offline
                  F Offline
                  Frank Olorin Rizzi
                  wrote on last edited by
                  #8

                  OK, before I give up on this, let me rephrapse the question :-) Any way I can stick in a C# App the following lines? sqlr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &h_env); sqlr = SQLSetEnvAttr(h_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_UINTEGER); and other statements like that ? They are taken from a C/C++ app that includes and . Maybe I can place them in an un-managed section? It would solve soooo many problems ! Thanks in advance for any input, F.O.R.

                  J 1 Reply Last reply
                  0
                  • F Frank Olorin Rizzi

                    OK, before I give up on this, let me rephrapse the question :-) Any way I can stick in a C# App the following lines? sqlr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &h_env); sqlr = SQLSetEnvAttr(h_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_UINTEGER); and other statements like that ? They are taken from a C/C++ app that includes and . Maybe I can place them in an un-managed section? It would solve soooo many problems ! Thanks in advance for any input, F.O.R.

                    J Offline
                    J Offline
                    Jim MacDonald 0
                    wrote on last edited by
                    #9

                    This is just a shot in the dark but you could take a look at addng a COM reference to the Microsoft SQLDMO Object Library. You might find what you need in there.

                    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