Help me to deploy application with database

praveen242424

Member
Joined
Sep 30, 2013
Messages
7
Location
Coimbatore, Tamil Nadu, India
Programming Experience
Beginner
I had a vb.net application with database connection. I am using Microsoft visual studio 2010 for developing windows application and Microsoft SQL Server 2008 for database access. My question is how to deploy the application and how to install it in other computers.

I've tried a step but when installing in another computer, it raises an error "A network related or instance specific error occured while establishing connection to sql server.(provider:SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)."

Please help me to resolve this.
 
You have to actually have an SQL instance installed somewhere accessible, otherwise you also need to install SQL Server 2008. Also make sure that you have a way to configure the instance address.
 
How did you create the database in the first place? Did you open Management Studio and add the database to your SQL Server instance or did you add the MDF file directly to your project? If the database will be accessed only by one instance of your app then the second option may be simpler because it makes deployment easier. You still need a SQL Server instance no matter what, but SQL Server Express can be installed automatically along with your app.
 
How did you create the database in the first place? Did you open Management Studio and add the database to your SQL Server instance or did you add the MDF file directly to your project? If the database will be accessed only by one instance of your app then the second option may be simpler because it makes deployment easier. You still need a SQL Server instance no matter what, but SQL Server Express can be installed automatically along with your app.

I had creaqted my database in the server explorer by adding new database and creating a new mdf file.

Please give me step by step instructions to deploy my app. Because I'm new to programming.

Thanks in advance.
 
OK then. You can publish your project to create a ClickOnce installer or, if you're using a paid-for edition of VS, create a Setup project and, in both cases, simply check the box for SQL Server Express in the Prerequisites dialogue to have it automatically installed along with your app if it's not already there. I'm not going to provide step-by-step instructions because there's plenty of information about deployment available in the MSDN Library and you should undoubtedly be reading some of that regardless.

If you're going to use ClickOnce then you should start with the Publish page of the project properties. Your keyboard has an F1 key and your IDE has a Help menu so you should learn to use them. If you have issues along the way then I'm more than happy to help with them but I'm not here so that you don't have to look at all for yourself. Look first, ask questions later. If you have issues, tell us what you've done and where you're stuck and we'll see what we can do.
 
I've recreated the application with sql compact server 3.5 database. When debugging I got an error that the ExecuteNonQuery:Connection property has not been initialized.

The connection string I'm Using is con.ConnectionString = "database=|DataDirectory|\soldier.sdf;"

Help me to resolve this
 
This is my program please help me to resolve this

Imports System.Data.SqlClient
Public Class Form1
Dim con As SqlConnection
Dim com As SqlCommand
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'SoldierDataSet3.Details' table. You can move, or remove it, as needed.
Me.DetailsTableAdapter.Fill(Me.SoldierDataSet3.Details)
'TODO: This line of code loads data into the 'SoldierDataSet2.Specialization' table. You can move, or remove it, as needed.
Me.SpecializationTableAdapter.Fill(Me.SoldierDataSet2.Specialization)
'TODO: This line of code loads data into the 'SoldierDataSet1.Rank' table. You can move, or remove it, as needed.
Me.RankTableAdapter.Fill(Me.SoldierDataSet1.Rank)
'TODO: This line of code loads data into the 'SoldierDataSet.BloodGroup' table. You can move, or remove it, as needed.
Me.BloodGroupTableAdapter.Fill(Me.SoldierDataSet.BloodGroup)
con = New SqlConnection
com = New SqlCommand
con.ConnectionString = "Data Source=\soldier.sdf;Persist Security Info=False;"
con.Open()
com.Connection = con
Label1.Visible = False
Label10.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label8.Visible = True
Button1.Visible = False
Button2.Visible = False
DataGridView1.Visible = False
RadioButton1.Visible = True
RadioButton2.Visible = True
TextBox1.Visible = False
TextBox2.Visible = False
TextBox3.Visible = False
TextBox4.Visible = False
TextBox5.Visible = False
TextBox6.Visible = False
ComboBox1.Visible = False
ComboBox2.Visible = False
ComboBox3.Visible = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Then
MsgBox("Fill all the Details")
End If
com.CommandText = "insert into Details values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & ComboBox1.SelectedValue & "','" & ComboBox2.SelectedValue & "','" & TextBox4.Text & "','" & ComboBox3.SelectedValue & "','" & TextBox5.Text & "','" & TextBox6.Text & "')"
com.ExecuteNonQuery()
MsgBox("The Data has been successfully inserted!!!!!")
RadioButton2.Visible = True
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
DataGridView1.Refresh()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RadioButton2.Visible = True
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
ComboBox1.ResetText()
ComboBox2.ResetText()
ComboBox3.ResetText()
DataGridView1.Update()
End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label8.Visible = True
Label10.Visible = True
Button1.Visible = True
Button2.Visible = True
RadioButton2.Visible = True
DataGridView1.Visible = False
TextBox1.Visible = True
TextBox2.Visible = True
TextBox3.Visible = True
TextBox4.Visible = True
TextBox5.Visible = True
TextBox6.Visible = True
ComboBox1.Visible = True
ComboBox2.Visible = True
ComboBox3.Visible = True
End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label8.Visible = False
Label9.Visible = True
Label10.Visible = False
Button1.Visible = False
Button2.Visible = False
DataGridView1.Visible = True
RadioButton1.Visible = True
TextBox1.Visible = False
TextBox2.Visible = False
TextBox3.Visible = False
TextBox4.Visible = False
TextBox5.Visible = False
TextBox6.Visible = False
ComboBox1.Visible = False
ComboBox2.Visible = False
ComboBox3.Visible = False
End Sub
End Class
 
Please don't post ALL your code. It just makes it harder to find the issue. Post only the RELEVANT code. That would be where the exception is thrown to begin with and anything else that you specifically consider relevant or that we ask for. Code that hides and shows controls is obviously not relevant to a database call.
I've recreated the application with sql compact server 3.5 database. When debugging I got an error that the ExecuteNonQuery:Connection property has not been initialized.

The connection string I'm Using is con.ConnectionString = "database=|DataDirectory|\soldier.sdf;"

Help me to resolve this
Your connection string is irrelevant. It's telling you that the Connection property has not been set. What object there has a Connection property? The clue is that you called ExecuteNonQuery on a command object.
 
I've recreated the application with sql compact server 3.5 database. When debugging I got an error that the ExecuteNonQuery:Connection property has not been initialized.

The connection string I'm Using is con.ConnectionString = "database=|DataDirectory|\soldier.sdf;"

Help me to resolve this

By the way, this question has nothing to do with the topic of this thread so it doesn't belong in this thread. If you've switched to SQL Server CE then you've solved your deployment issue so this thread is resolved. If you have a new question on a new topic then it belongs in a new thread. One topic per thread and one thread per topic.
 
Back
Top