Step by step to deploy VB.net project.

damxuanthai

Well-known member
Joined
Mar 1, 2007
Messages
48
Location
Việt Nam.
Programming Experience
Beginner
I have read all threads in this topic (deployment) but I'm still don't know clearly How to deploy a Vb.net app using SQLdatabase.
AnyBody can show me step by step How to deploy. I want to make a msi file to install my app in other PC Which don't connect to Internet.
Thanks alot.
 
Dear JohnH.
I have try with ClickOnce and found that, the directory in Which the App installed to is not "Program files" but in the other Directory Which locate at Localsettings\Apps..., So path and name of Directory is very long, it make the SQLconnection string very long in "DataDirectory" parameter, and make the Error.
Are there any way to set the other destination Directory in ClickOnce? and change to "Program files"
 
Not that I'm aware of, ClickOnce is generally not configurable. Are you sure the |DataDirectory| constant give error? I know the real path when I tested this was about 150 chars long, but the connectionstring instruction as posted above was only around 30 characters when using the constant.
 
Im sure Error was given by |DataDirectory| Please see the Picture: look at the red underlines.
 

Attachments

  • Error.JPG
    Error.JPG
    103.9 KB · Views: 73
I have made a test. I copied the folder in Which my app installed to C: driver.
And It did not appear Error. That's amazing. I dont know How was make Error. Please see the capture:
 

Attachments

  • Error.JPG
    Error.JPG
    82.5 KB · Views: 67
But I don't get it, where did you get that connectionstring from? It's not supposed to look like that, it's should be like the one I quoted in post 15:
AttachDbFilename=|DataDirectory|\DBTestOnly.mdf;
I check with the Connection of my TableAdapter and it says the same, it does not write the path, it uses the constant value.
VB.NET:
MsgBox(Table1TableAdapter.Connection.ConnectionString)
 
Dear JohnH. I will send to you my code: this form1's code
VB.NET:
Imports System.Data.SqlClient
Public Class Form1
 Dim gscon As String
 
  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    TextBox1.Text = "Data Source=" & System.Environment.MachineName & "\SQLexpress;Initial Catalog=;integrated security = true; AttachDBFileName=" & Application.StartupPath & "\DbTestOnly.mdf"
  End Sub
 
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   gscon = TextBox1.Text
   Dim TemTable As New DataTable
   Dim strError As String = ""
   Dim myDT As New DataTable
   Dim myCon As New SqlConnection(gscon)
   Try
      myCon.Open()
      Dim myData As New SqlDataAdapter("Select * from tblName", myCon)
      myData.Fill(myDT)
   Catch ex As Exception
      strError = ex.Message
   Finally
      myCon.Close()
      myCon.Dispose()
   End Try
   If Not strError.Equals("") Then
      MsgBox(strError)
   End If
   dgdV1.DataSource = myDT
  End Sub
End Class
 
It is true that I use this way to get SQLconnection String for AttachDbFilename parameter:
VB.NET:
 "Data Source=" & System.Environment.MachineName & "\SQLexpress;Initial Catalog=;integrated security = true; AttachDBFileName=" & Application.StartupPath & "\DbTestOnly.mdf"
Are there another ways to define it?
 
Dear to JohnH. I have try many many times. Now I give U a good news: I have done this Thread. The Error do not appear again when I add ";User Instance=True" to my SQLconnection string. This is correct:
VB.NET:
"Data Source=" & System.Environment.MachineName & "\SQLexpress;Initial Catalog=;integrated security = true; AttachDBFileName=" & _
_Application.StartupPath & "\DbTestOnly.mdf;User Instance=True"
Thanks alot for your help in this thread.
But I dont know clearly about the role of parameter ";User Instance=True". When using this parameter, SQLconnection did well, I checked in SQL managerment and could not find any Database attached to. See again in Post #21, once time SQLconnnection did well, I checked in SQLmanager, there is a database was attached. How is the difference?
Thank again, Mr JohnH.
ĐÀM XUÂN THÁI.
 
This is correct:
VB.NET:
"AttachDBFileName=" & _
_Application.StartupPath & "\DbTestOnly.mdf"
That is not correct from what I have been saying many times now, and it is not where ClickOnce deploys the database. Do you need it one more time?
VB.NET:
"AttachDBFileName=|DataDirectory|\DbTestOnly.mdf"
 
Back
Top