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. Visual Basic
  4. What's the best way to do?

What's the best way to do?

Scheduled Pinned Locked Moved Visual Basic
questiondatabasewindows-admin
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.
  • L Offline
    L Offline
    Lisana
    wrote on last edited by
    #1

    In my vb app, I have a sql connect string in my publicModule. when the user install the app, it will ask the "Initial Catalog" and "Data Source" value, then open the app. if the user input the wrong value, then the app can't open the sql data, how can I check the two value are matching in the sql data? and what's the best way to put the sql connection string in my app. I created a registry key for the two value. Is it the best way? how can I check the registry key if it's not exist? Lisa

    D 1 Reply Last reply
    0
    • L Lisana

      In my vb app, I have a sql connect string in my publicModule. when the user install the app, it will ask the "Initial Catalog" and "Data Source" value, then open the app. if the user input the wrong value, then the app can't open the sql data, how can I check the two value are matching in the sql data? and what's the best way to put the sql connection string in my app. I created a registry key for the two value. Is it the best way? how can I check the registry key if it's not exist? Lisa

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      When your application starts, it should check to see if there are values in the appropriate storage locations for your Inital Catalog and Data Source. These could be in the Registry or in a config file somewhere. If the values are not there, then your app should ask for them. Once you have them, either input by the user or fetched out of the saved config, you can try and connect to the database and run a small query. If any part of the query process fails, then you can be pretty sure something is wrong and the code should return any errors to the user and either ask for corrected, or alternate, connection information or quit. In my work, I like to setup a stored procedure in the database that returns a value specific to that database. For example, returning a string that specifies what the database name is, it's code version and its schema revision, like "TSEC ver:2.00 schema:6.30". This way, my code knows that this database is the correct one it should be working with, regardless of what the Data Source name is(!) and it gets additional information that the application might need. Such as taking into account dealing with an older version of a database's procedures or dealing with a minimum database version that's supported by the code. Currently, Microsoft recommends NOT using the registry to store application configuration values, such as a connection string, but instead, recommends using .config files. Rocky Lhotka wrote a very good article for MSDN, found here[^], that explains configuration files and how to read and write them. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      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