Data source transportability
-
Monday, August 25, 2008 6:22 PMOk, this is frustrating!
I've created an application (Visual Basic, Visual Studio 2008 - Express Edition) that uses a single data source. I want to use the app on another machine.
How do I transport the data source along with the application?? I have already moved the database over, but need to create the data source connector on that new machine.
Thanks in advance...
Dennis
- Edited by Dr.DennisNeder Monday, August 25, 2008 6:24 PM Visual Studio 2008 added
All Replies
-
Monday, August 25, 2008 8:41 PM
The datasource should be included in the compiled .exe. I may not be understanding what your issue is, but you will need to repoint the connection string to the new database. Suggestion: include the connection string in your app.config or web.config file (you may need to add one to the project.)- Proposed As Answer by 82edwards Thursday, August 28, 2008 4:31 PM
- Marked As Answer by Martin Xie - MSFT Friday, August 29, 2008 5:26 AM
-
Friday, August 29, 2008 5:40 AM
Dr.DennisNeder said:
I've created an application (Visual Basic, Visual Studio 2008 - Express Edition) that uses a single data source. I want to use the app on another machine.
How do I transport the data source along with the application?? I have already moved the database over, but need to create the data source connector on that new machine.
Thank you David for your friendly help.
Hi Dennis,
If you intend to deploy your application with one database to other machines via ClickOnce in VB 2008 Exprress, please check this walkthrough:
1. Add existing item ( select your database file such as SQL Server database file SqlDatabase.mdf) to your Windows Forms Application project.
2. Drag&drop DataGridView1 on Form1. Using |DataDirectory| path in database connection string.Imports System.Data.SqlClient Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim con As SqlConnection = New SqlConnection("Data Source=.;Integrated Security=True;AttachDbFilename=|DataDirectory|\SqlDatabase.mdf") Dim cmd As SqlCommand = New SqlCommand("SELECT * FROM Table1", con) con.Open() Dim myDA As SqlDataAdapter = New SqlDataAdapter(cmd) Dim myDataSet As DataSet = New DataSet() myDA.Fill(myDataSet, "MyTable") DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView con.Close() con = Nothing End Sub End Class 3. Select SQL Server database file SqlDatabase.mdf in Solution Explorer and look at its properties:
Make sure that property "Build Action" = "Content" .
and "Copy to Output Directry" = "Copy if newer"
4. Then open Publish tab in Project Property -> Press "Application Files" Button
Make Sure that your database file in list and its publish status = Data File (Auto) and Download Group = (Required)
Then publish your application. Your SQL Server database file will be deployed with application in "Data" folder of Installation folder of your application. An exe.config file also be deployed with application in Installation folder of your application.
Please check this thread for detailed instruction:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3526469&SiteID=1
"ClickOnce deployment of Access database"Trackback: http://forums.msdn.microsoft.com/en-US/vbgeneral/thread/3e277e3d-f2f9-47ca-b260-03371aca834b
Best regards,
Martin Xie- Marked As Answer by Martin Xie - MSFT Tuesday, September 02, 2008 11:08 AM

