6 Replies - 506 Views - Last Post: 05 December 2012 - 09:20 PM Rate Topic: -----

#1 Lethugs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-November 12

How can I specify the Server of my database when I make my project exe

Posted 05 December 2012 - 03:47 AM

I have this module I call every time i modify my database

 Public Sub main()

constr = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:"database file".mdf;" & _
"Integrated Security=True;Connect Timeout=30;User Instance=True"
Con = New SqlConnection(constr)
Try
Con.Open()
'MsgBox("Server Connection is Open ! ")
'frmMain.Connection.Text = "Connecting To serv``er"
Con.Close()
Catch ex As Exception
MsgBox("Sorry Can not open connection ! ", vbCritical, "Database")
End Try

End Sub


My project will be installed on several computers. The database in integrated in my project since i used Service-Based Database. Meaning when I transfer the project to different computers the database always comes with it.

I'm thinking that when I will make an executable project, the database will be included. How will I change the datasource above during installation of my project just to ensure that there will be a single server for my database?

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: How can I specify the Server of my database when I make my project exe

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9096
  • View blog
  • Posts: 34,172
  • Joined: 12-June 08

Re: How can I specify the Server of my database when I make my project exe

Posted 05 December 2012 - 08:09 AM

Assuming the exe and the mdf file are in the same directory - why not just use

My.Computer.FileSystem.CurrentDirectory

Was This Post Helpful? 0
  • +
  • -

#3 Lethugs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-November 12

Re: How can I specify the Server of my database when I make my project exe

Posted 05 December 2012 - 06:31 PM

I will install this application to different machines, I know that since the database is integrated within the application, I mean it is inside its folder, let say example.mdf, it always comes with it when deployed. Using the module above, if I run the application It will access this example.mdf in its local machine, what I need is when I install this app, I can choose a server over a network then automatically change the data source in my module so that there will only be one database server.

I hope I explained it right
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9096
  • View blog
  • Posts: 34,172
  • Joined: 12-June 08

Re: How can I specify the Server of my database when I make my project exe

Posted 05 December 2012 - 06:56 PM

You would put the connection string info in the app.config file.. modify as needed.. and it should work.
Was This Post Helpful? 0
  • +
  • -

#5 Lethugs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-November 12

Re: How can I specify the Server of my database when I make my project exe

Posted 05 December 2012 - 08:50 PM

The connection string info is in the app.config also. I will deploy my application and make executable burned to a cd. If i will install my application from that cd, how will i modify the datasource of the module above such that there will be only one server of the database shared over the network? since that module is called inside my form codes
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9096
  • View blog
  • Posts: 34,172
  • Joined: 12-June 08

Re: How can I specify the Server of my database when I make my project exe

Posted 05 December 2012 - 08:58 PM

... again.. in the app config.. before you burn this off and send it have the datasource available... or at worst have the app ask for the connection string and save it to the my.settings.
Was This Post Helpful? 0
  • +
  • -

#7 Lethugs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-November 12

Re: How can I specify the Server of my database when I make my project exe

Posted 05 December 2012 - 09:20 PM

How will i create an exe file such that if the user install it, it will ask the connection string? Is there something i need to configure during creation of exe? or do I need to create a program inside my app that will ask the connection string from the user? Sorry for this because i'm just newbie with this. The last time i made an exe file, not like this situation
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1