locked
couldnt connect to database

    Question

  • how a database software is developed?
    i tried using sql server, the weak thing is that.....the database software is unable to run in a pc that is not installed sql server program. how can i solve this? using others software instead of sql? or is there any other way that possible to let my database program to access database data without required sql installed.

    thanks...
    Friday, February 13, 2009 3:46 PM

All replies

  • kentck86 said:

    how a database software is developed?
    i tried using sql server, the weak thing is that.....the database software is unable to run in a pc that is not installed sql server program. how can i solve this? using others software instead of sql? or is there any other way that possible to let my database program to access database data without required sql installed.

    Hi kentck,

    Welcome to MSDN forums!

    Based on my understanding, you want to publish a database application and deploy to client machines which might not have SQL Server installed.

    If you use ClickOnce Deployment to publish database application in VB.NET, you can solve this issue by choosing SQL Server 2005 Express Edition as a prerequisite.
    Project Property -> Publish tab -> Press "Prerequisites" Button -> In the Prerequisites dialog, choose "SQL Server 2005 Express Edition".
    Thus, when deploying, if client machine doesn't have SQL Server installed, the SQL Server will be installed immediatelly; if client machine has SQL Server installed, then skip.


    In addition,
    Walkthrough: How to publish/deploy WinForms application including a database file via ClickOnce?

    1) Create a new Windows Forms application.

    2) Add Data Source (select a database file such as SqlDatabase.mdf) to your project.

    3) Drag&drop DataGridView1 onto Form1, and using |DataDirectory| path in database connection string.

    Imports System.Data.SqlClient

    Public Class Form1

        'Binding database table to DataGridView

        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

    4) Select SqlDatabase.mdf file in Solution Explorer and look at its properties:

          Make sure the "Build Action" property is set as "Content".

          The "Copy to Output Directory" property is set as "Copy if newer".

    5) Project Property -> Publish tab -> Press "Application Files" Button

        Check the database file in list, and make sure its “Publish Status” is set as “Data File (Auto)” and “Download Group” is set as "(Required)”.
    6)    Project Property -> Publish tab -> Click “Publish” button to publish your application.

     The database file will be deployed with application in "Data" folder of application Installation folder. An exe.config file will also be deployed along with application in application Installation folder.

    Related thread:
    http://social.msdn.microsoft.com/forums/en/vbgeneral/thread/92a2afc5-f168-454d-8e8b-6967aad45b72/



    Best regards,
    Martin Xie

    • Marked as answer by Martin Xie - MSFT Thursday, February 19, 2009 6:19 AM
    • Unmarked as answer by kentck86 Saturday, February 28, 2009 4:15 PM
    Thursday, February 19, 2009 6:17 AM