Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Help Sql Connection

connection

  • Please log in to reply
4 replies to this topic

#1 CodeWarrior

CodeWarrior

    CC Lurker

  • New Member
  • Pip
  • 4 posts
  • Programming Language:Visual Basic .NET
  • Learning:C#, (Visual) Basic, Python, Visual Basic .NET

Posted 21 May 2012 - 10:37 AM

Hello guys is there any body can help me about my connection string. here is my problem
i am created an database name MyDBase.mdf is located to my Other PC Server. The Directory is
C:\TestProjectServerDatabase\TestProjectServerDatabase\bin\Debug\MyDBase.mdf

Now i test for this connection string

Dim ServerStr As String = "Provider=SQLOLEDB;Server=.\SQLExpress;AttachDbFilename=C:\TestProjectServerDatab​ase\TestProjectServerDatabase\bin\Debug\MyDBase.mdf;Database=dbname; Trusted_Connection=Yes;"
it work fine because it is located correct to the directory and the provider

but if i'm trying to other pc and i change the Server Name and location of the database now it give me an error

Dim ServerStr As String="Provider=SQLOLEDB;Server=MyServer;AttachDbFilename=C:\TestProjectServerDatabase\​TestProjectServerDatabase\bin\Debug\MyDBase.mdf;Database=dbname; Trusted_Connection=Yes;"
MyServer is the name of my server PC i try also an IP but its the same error...
please help me guys... more power
  • 0

#2 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 21 May 2012 - 03:43 PM

check here: http://connectionstrings.com/

Wait. What db are you using? You can't access a file system on another machine.

Server=myServerName heInstanceName;Database=myDataBase;Trusted_Connection=True;
  • 0
My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth

#3 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 21 May 2012 - 04:16 PM

remove the attachdbfilename, and just manually attach the file into your SQL server :)
  • 0
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#4 CodeWarrior

CodeWarrior

    CC Lurker

  • New Member
  • Pip
  • 4 posts
  • Programming Language:Visual Basic .NET
  • Learning:C#, (Visual) Basic, Python, Visual Basic .NET

Posted 21 May 2012 - 07:46 PM

Sir my project is stand alone database that will located to Program File under his Directory Folder if the Software Installed it will created to the directory of Program File
so i pack two software for distribution Server and Client Application.... so if the client installed to client server the setting only to be change is Server Name or IP
  • 0

#5 Abu Ehab

Abu Ehab

    CC Newcomer

  • Member
  • PipPip
  • 11 posts

Posted 30 May 2012 - 12:54 PM

Okey :
Try This :
Dim Cn As New SqlConnection("Provider=SQLOLEDB;Server=.\SQLExpress;AttachDbFilename=" & Application.StartupPath & "\MyDBase.mdf;Database=dbname; Trusted_Connection=Yes;")

  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download