Results 1 to 12 of 12

Thread: Want vb6 code to attach sql server database

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2012
    Posts
    41

    Question Want vb6 code to attach sql server database

    I Want vb6 code to attach sql server database So when any one install the program it works without need to attach database
    and many thanks for all

  2. #2
    Frenzied Member
    Join Date
    Jan 2009
    Location
    Watch Window(Shift+f9)
    Posts
    1,879

    Re: Want vb6 code to attach sql server database

    No need for any Code .just package your exe and related database file .using Package and deployment wizard .see the following link for more detail.
    http://msdn.microsoft.com/en-us/libr...(v=vs.60).aspx

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2012
    Posts
    41

    Re: Want vb6 code to attach sql server database

    firoz-raj Thank you for Reply But this project with SQL SERVER DATABASE AND Must be Attached SO That The Program Can Connect To It

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,733

    Re: Want vb6 code to attach sql server database

    Can you explain what you mean with attach a database?
    Is there an SQL Server database already up and running and you need to connect to it?
    Or do you need to do an install of SQL server and your application?

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2012
    Posts
    41

    Re: Want vb6 code to attach sql server database

    I need to do an install of SQL server and my application And the database file to be attached on the sql server from my vb6 code . so any one can install my program with sql express in the installation file and when he run program first time the database will be attached to the server

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Want vb6 code to attach sql server database

    You can attach a database using a connection string (which you use in the normal way), such as this one:
    Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;Trusted_Connection=Yes;
    Source: http://www.connectionstrings.com/sql-server/ , also contains this note:
    Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

  7. #7

    Thread Starter
    Member
    Join Date
    Jul 2012
    Posts
    41

    Re: Want vb6 code to attach sql server database

    Can I Do This With VB6

    I USE This Connection String
    DataEnvironment1.Connection1.ConnectionString = "Provider=SQLOLEDB.1;OLE DB Services = -2 ;Password=Mypass;Persist Security Info=True; User ID=sa;Initial Catalog=DBNAME;Data Source = 192.168.0.1 "

  8. #8
    Frenzied Member
    Join Date
    Jan 2009
    Location
    Watch Window(Shift+f9)
    Posts
    1,879

    Re: Want vb6 code to attach sql server database

    change the connection string like the following .

    Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;Trusted_Connection=Y es;

    Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Want vb6 code to attach sql server database

    Quote Originally Posted by dawoud66 View Post
    Can I Do This With VB6
    Yes, it may just be as simple as adding the part I highlighted to your current connection string.

    I recommend you ignore firoz.raj's post, as he has (once again) posted something that he should know is wrong.

  10. #10

    Thread Starter
    Member
    Join Date
    Jul 2012
    Posts
    41

    Re: Want vb6 code to attach sql server database

    si_the_geek : Is Your connection will be done with SQL Server 2000 , 2005 ,2008 and 2012

  11. #11
    Frenzied Member
    Join Date
    Jan 2009
    Location
    Watch Window(Shift+f9)
    Posts
    1,879

    Re: Want vb6 code to attach sql server database

    Yes, it may just be as simple as adding the part I highlighted to your current connection string.

    I recommend you ignore firoz.raj's post, as he has (once again) posted something that he should know is wrong.
    brother how it is wrong ?.

    Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;Trusted_Connection=Yes;

  12. #12
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Want vb6 code to attach sql server database

    Quote Originally Posted by dawoud66 View Post
    si_the_geek : Is Your connection will be done with SQL Server 2000 , 2005 ,2008 and 2012
    I'm not sure which versions support it (I'm fairly certain that 2008 onwards all do), so that is something you will need to research (there should be info on msdn.microsoft.com ) or find out by testing.

    Quote Originally Posted by firoz.raj View Post
    brother how it is wrong ?.

    Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;Trusted_Connection=Yes;
    That part is wrong because it is an exact copy of what I posted (so you were just wasting the time of everybody who read it).

    The other connection string you posted is wrong because it is for .Net rather than VB6

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width