VB.NET应用程序无法在其他计算机上运行

时间:2014-07-22 17:53:26

标签: mysql database vb.net visual-studio-2013

我可以毫无错误地调试我的项目,但是当我构建它并将可执行应用程序复制到另一台计算机时,应用程序根本没有运行。表格甚至没有出现在屏幕上。

Here)是我的错误的屏幕截图。

这是我的源代码。

Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient

Public Class Form1
    Dim MySQLConnection = New MySqlConnection
    Dim Command As New MySqlCommand
    Dim MyAdapter As New MySqlDataAdapter
    Dim sqlCommand As New MySqlCommand
    Dim str_carSql As String


    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim response As Boolean = False
        Button1.Enabled = False
        Try
            response = My.Computer.Network.Ping("www.db4free.net")
            Label2.Text = "ONLINE"
            Label2.ForeColor = Color.Green
            Button1.Enabled = True
        Catch ex As Exception
            Label2.Text = "OFFLINE"
            Label2.ForeColor = Color.Red
            MsgBox("No internet connection!", MsgBoxStyle.Critical)
        End Try
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Cursor = Cursors.WaitCursor
        Try
            MySQLConnection.ConnectionString = "server=db4free.net ;port=3306; user=prav5ef; password=prav5eF; database=databasetest;"
            MySQLConnection.Open()
            MsgBox("Connected to server!")
        Catch ex As Exception
            MsgBox("Failed connecting to server!", MsgBoxStyle.Critical)
        End Try
        Try
            str_carSql = "insert into databasetest (id,name,password) values (@id,@name,@password)"
            sqlCommand.Connection = MySQLConnection
            sqlCommand.CommandText = str_carSql
            sqlCommand.Parameters.AddWithValue("@id", TextBox1.Text)
            sqlCommand.Parameters.AddWithValue("@name", TextBox2.Text)
            sqlCommand.Parameters.AddWithValue("@password", TextBox3.Text)
            sqlCommand.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox("ID existed: Could not insert record")
        End Try
        MsgBox("Done")
        Application.Restart()
    End Sub
End Class

以下是应用程序假设显示的内容:

enter image description here

我使用的在线数据库是db4free.net: enter image description here

1 个答案:

答案 0 :(得分:1)

由于您未提供有关错误的足够信息,因此以下是您可能遇到的问题以及所述问题的解决方案:

答。)您的客户可能没有为您的程序运行正确的.NET框架。在这种情况下,请通过下载here.

来安装正确的.NET Framework

B。)您没有在客户端单元上包含mysl.data.dll。在这种情况下,请从here下载.dll并将其安装在客户端单元中。