Deploy Program with associated Database?
I'm hoping someone can help me out here. I've completed my latest program and am ready to deploy it to an office here in town. However, I'm not sure what the best method is? Here is my situation.
I know I can't use click once, so i need to create a setup package using visual studios setup, or the other one many here us. (I don't remember the name right now but will find that later).
I have a database all setup on my machine that talks to my code. I need to deploy this program to my clients office and deploy this database with it. However, i want all the machines in the office to install the program, and they all talk to the same database on their server.
So what I'm thinking is, i need to copy the database to their SQL server, or SQL server express. Have the users in the office install my application then somehow hook the program that was once connected to the database on my development computer to theirs. But I'm thinking the program wont recognize the database on their server, and keep looking for myn?
If anyone has any advice i would really appreciate it.
Re: Deploy Program with associated Database?
Yes, You will need a configuration file that you can change to match the parameter of their database or create an ODBC configuration on each computer for the database. If you have chard coded your database location you will need to change it (It never should be that way in the first place).
The other package probably is Inno Setup...
Re: Deploy Program with associated Database?
Ok, i found my solution created a an app.config file.
Here is the contents. I see in there that there is a connection string part. How would i modify this to the clients database location during the application install?
I'm thinking I'm gonna need to install SQL server express on their server for them, then copy my database to their server. But how would i get my program to see the database or adjust this configuration file to see the new location of the database? Can this be done in InnoSetup? Do you know of a tutorial on how to accomplish this? I've searched InnoSetups help, but no luck on items pertaining to databases.
Again they probably will be using SQL server express right now, until i can talk them into the full version.
Thank you very much for the help thus far!!
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="In_Out_Log.My.MySettings.DIS_In_OutConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\DIS_In_Out.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
</configuration>
Re: Deploy Program with associated Database?
One other question. You said not to hard code the database location? Does this mean don't use the "Connect to Data Source"? Then dragging and dropping datagridviews onto my forms?
Or can i ONLY fill my datagrid views using sql commands in vb.net like this? Then read from like the registry where the database path is, and replace this code below with "Data Source=server;Initial Catalog=\\myserver\databases\MKM_Dbase.mdf;Integrated Security=True"
Or am i totally off?
Code:
'This selects a row in the datagridview.
Dim conn As New SqlClient.SqlConnection("Data Source=server;Initial Catalog=MKM_Dbase;Integrated Security=True")
Dim dt As New DataTable
Try
Dim da As New SqlClient.SqlDataAdapter("SELECT * FROM jobs WHERE JobNumberID =@ID", conn)
da.SelectCommand.Parameters.AddWithValue("@ID", Trim(Microsoft.VisualBasic.Left(Me.JobNumberIDTextBox.Text, 7)))
da.Fill(dt)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Thanks again!!
Re: Deploy Program with associated Database?
You seem to be using ODBC is that true? Not hard coding the data source would be using ADO and an OLE DB connection. And yes you can change Ini files from Inno Setup otherwise you will need a configuration app included with your installation.
Not hard coding locations or using ODBC makes your app more flexible.
Re: Deploy Program with associated Database?
No, he is using an SqlConnection, which is basically a special OLEDB connection for SQL Server.
The only hard-coding is the server and database names, which may well be appropriate (if this is running in a network where all of the users will connect to the same SQL Server). The path of the "data file" is not important, except while running the Attach.
Quote:
I'm thinking I'm gonna need to install SQL server express on their server for them, then copy my database to their server.
Correct.
Quote:
But how would i get my program to see the database or adjust this configuration file to see the new location of the database?
I'm not sure I'm afraid.
Re: Deploy Program with associated Database?
Quote:
Originally Posted by si_the_geek
I'm not sure I'm afraid.
Ok, :( .. So is the safest way, deploy the database to their SQL server express, then attach the database to my program, then publish it, and be done? I know this will work, but requires me to have a separate solution of code for each client, and requires me to visit each location and set this up.
Is there any other ways to get a database loaded on up a clients network where all users point to the same database to run the program?
Thanks again guys for help!!
Re: Deploy Program with associated Database?
Deploying a configuration file is probably best. This would mean having two installation, One for the server and one for the client. once you deploy the server installtion you create the configuration file in a location where the clients will look for it. IE. in a shared folder. When you deploy the client installation you will look in the know spot for the configuration file and know the name, IP and any other information that you need for your client installations.