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 generalize SQL queries

how to generalize SQL queries

Scheduled Pinned Locked Moved Database
databasehelpcsharpalgorithmstutorial
2 Posts 2 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.
  • P Offline
    P Offline
    puppiesLover
    wrote on last edited by
    #1

    I'm doing some database in C# using MS SQL. Problem #1: Everytime i do a connection to my database, i have to copy and paste the code over and over. I heard of a way to put these code in the configuration file, but i don't know how to. Problem #2: I also heard of someway(interface, object) allowing me to do SQL query indirectly instead of passing the query string directly into the SqlCommand object. And, again, I don't know how to. Problem #3: Is there anyway i can pass in my sql query dynamically(ie, as a varible)? I just learn C# on my own, and having problem searching for things like this Please help me out! THANKS A BUNCH!!!

    M 1 Reply Last reply
    0
    • P puppiesLover

      I'm doing some database in C# using MS SQL. Problem #1: Everytime i do a connection to my database, i have to copy and paste the code over and over. I heard of a way to put these code in the configuration file, but i don't know how to. Problem #2: I also heard of someway(interface, object) allowing me to do SQL query indirectly instead of passing the query string directly into the SqlCommand object. And, again, I don't know how to. Problem #3: Is there anyway i can pass in my sql query dynamically(ie, as a varible)? I just learn C# on my own, and having problem searching for things like this Please help me out! THANKS A BUNCH!!!

      M Offline
      M Offline
      Mike Osbahr
      wrote on last edited by
      #2

      puppiesLover wrote: Problem #1: Everytime i do a connection to my database, i have to copy and paste the code over and over. I heard of a way to put these code in the configuration file, but i don't know how to. Depends on the type of database connector you're using, I guess. If you drop an SQL data connection onto a form, the IDE will automatically generate the code for it. If the generated connection string is not what is needed, I'll put code in the constructor to overwrite it. Be sure to place this code after the InitialComponents method call. >>>-----> MikeO

      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