Connection To Sql2005

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mafaisal
    New Member
    • Sep 2007
    • 142

    Connection To Sql2005

    Hello Experts

    I am Using Vb.Net 2005 And Sqlserver 2005

    My Doubt is

    Have we To Make Connection to Sql Like MsAcces..?
    ie When we install setup file in client system is any soln to restore sql backup
    file
    When we install setup file using vb.net install only engine of sql
    here we cannot find hw to restore bckup file
    Nw we Followed way is also install sqlExpressAdvan ced so we can get sqlservermanage ment studio using that we can restore
    But this is complicated, install setup, sqlExpress

    My Question is Is any soln To avoid this When we run setup automatically Restore sql or manually without installing Another tools
    or Any way to Connect sql like acces
    ie we can to connect by providing path of mdf file or back up file of Sql

    Please Give me Reply

    Faisal
  • LorenVS
    New Member
    • Mar 2008
    • 8

    #2
    Hello,

    There are a couple of ways to do this, and I'm not quite sure what you're asking, but here are two options:

    The easiest way would be to copy the .mdf file along with whatever application you are distributing and then use a connection string that attaches the .mdf file... Something along the lines of:

    Code:
    SqlConnection Con = new SqlConnection("Data Source=.\SQLEXPRESS;AttacheDBFilename=C:\\Path\\To\\Database.mdf;")
    Of course, you're probably going to need more parameters in your connection string, but that works fine as long as you're willing to have you're database reattached each time your app is started...

    The other way would be to script your entire database to a massive query, and run that the first time your application runs. Then, you would probably have to use SqlBulkCopy or so to transfer all your data from your original database server onto the new installations.. .

    Hope that helps,

    - Loren VS

    Comment

    • mafaisal
      New Member
      • Sep 2007
      • 142

      #3
      Hello

      Thanks Lorren For ur Reply

      I also Get this from

      Connectionstrin g

      Thanks alot

      Faisal

      Originally posted by LorenVS
      Hello,

      There are a couple of ways to do this, and I'm not quite sure what you're asking, but here are two options:

      The easiest way would be to copy the .mdf file along with whatever application you are distributing and then use a connection string that attaches the .mdf file... Something along the lines of:

      Code:
      SqlConnection Con = new SqlConnection("Data Source=.\SQLEXPRESS;AttacheDBFilename=C:\\Path\\To\\Database.mdf;")
      Of course, you're probably going to need more parameters in your connection string, but that works fine as long as you're willing to have you're database reattached each time your app is started...

      The other way would be to script your entire database to a massive query, and run that the first time your application runs. Then, you would probably have to use SqlBulkCopy or so to transfer all your data from your original database server onto the new installations.. .

      Hope that helps,

      - Loren VS

      Comment

      Working...