发布后联不上数据库!!!
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="宋体" size="3">我下面的这段测试数据库连接的代码,方法一不管在哪里都没有问题,方法二和方法三在我的开发环境没有问题(装有<span lang="EN-US">vs2005</span>和你破解的<span lang="EN-US">dw2.0</span>)通过<span lang="EN-US">vs2005</span>发布向导发布到其他干净机器上(装有数据库,没有<span lang="EN-US">VS2005</span>,没有<span lang="EN-US">dw2.0</span>)运行程序,方法一不会报错,但是方法二和方法三都在红色代码的地方报错,不知道什么原因?</font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><p><font face="宋体" size="3"> </font></p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">Imports Sybase.DataWindow</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">Imports System.Data.SqlClient</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">Public Class Form1</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span style="FONT-SIZE: 15pt; COLOR: red;"><font face="宋体">方法一<span lang="EN-US"><p></p></span></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Private Sub Button1_Click(ByVal sender As System.Object, ByVal ex As System.EventArgs) Handles Button1.Click</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Dim theConnection As New System.Data.SqlClient.SqlConnection("Data Source=localhost\SQLEXPRESS;Initial Catalog=Print;Integrated Security=SSPI;")</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Dim gSQLCA As New Sybase.DataWindow.AdoTransaction(theConnection, "")</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> theConnection.Open()</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("SqlClient.SqlConnection.open</span>成功<span lang="EN-US">")</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><p><font face="宋体" size="3"> </font></p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As NullReferenceException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>空指针异常<span lang="EN-US">: " + vbCrLf + vbCrLf + e.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As TransactionException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>事务错,连接数据库出错<span lang="EN-US">: " + vbCrLf + vbCrLf + e.SqlErrorText + vbCrLf + vbCrLf + e.SqlDbCode, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As InvalidOperationException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>非法操作,连接数据库出错<span lang="EN-US">: " + vbCrLf + vbCrLf + e.Message + vbCrLf + vbCrLf + e.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As Exception</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>异常操作,连接数据库出错<span lang="EN-US">: " + vbCrLf + vbCrLf + e.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Finally</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> End Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> End Sub</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span style="FONT-SIZE: 15pt; COLOR: red;"><font face="宋体">方法二</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Private Sub Button2_Click(ByVal sender As System.Object, ByVal ex As System.EventArgs) Handles Button2.Click</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Dim theConnection As New System.Data.SqlClient.SqlConnection("Data Source=localhost\SQLEXPRESS;Initial Catalog=Print;Integrated Security=SSPI;")</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Dim gSQLCA As New Sybase.DataWindow.AdoTransaction(theConnection, "")</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Dim SQLCA As New Sybase.DataWindow.AdoTransaction(theConnection, "")</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> theConnection.Open()</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("SqlClient.SqlConnection.open</span>成功<span lang="EN-US">")</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="宋体"><span lang="EN-US"><font size="3"> </font></span><span lang="EN-US" style="FONT-SIZE: 14pt; COLOR: red;"> SQLCA.BindConnection()<p></p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("SQLCA.BindConnection()</span>成功<span lang="EN-US">")</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As NullReferenceException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>空指针异常<span lang="EN-US">: " + vbCrLf + vbCrLf + e.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As TransactionException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>事务错,连接数据库出错<span lang="EN-US">: " + vbCrLf + vbCrLf + e.SqlErrorText + vbCrLf + vbCrLf + e.SqlDbCode, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As InvalidOperationException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>非法操作,连接数据库出错<span lang="EN-US">: " + vbCrLf + vbCrLf + e.Message + vbCrLf + vbCrLf + e.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As Exception</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>异常操作,连接数据库出错<span lang="EN-US">: " + vbCrLf + vbCrLf + e.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Finally</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> End Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> End Sub</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="宋体"><span style="FONT-SIZE: 15pt; COLOR: red;">方法二</span><span lang="EN-US"><font size="3"> </font></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Private Sub Button3_Click(ByVal sender As System.Object, ByVal ex As System.EventArgs) Handles Button3.Click</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Dim SQLCA As New Sybase.DataWindow.Transaction</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> SQLCA.Dbms = Sybase.DataWindow.DbmsType.OleDb</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> SQLCA.AutoCommit = True</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> SQLCA.DbParameter = "PROVIDER='SQLOLEDB',DATASOURCE='(local)\SQLEXPRESS',PROVIDERSTRING='database=Print',DelimitIdentifier='Yes',INTEGRATEDSECURITY='SSPI'"</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="宋体"><span lang="EN-US"><font size="3"> </font></span><span lang="EN-US" style="FONT-SIZE: 14pt; COLOR: red;">SQLCA.Connect()<p></p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox(" SQLCA.Connect()</span>成功<span lang="EN-US">")</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As NullReferenceException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>空指针异常<span lang="EN-US">: " + vbCrLf + vbCrLf + e.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As TransactionException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>事务错,连接数据库出错<span lang="EN-US">: " + vbCrLf + vbCrLf + e.SqlErrorText + vbCrLf + vbCrLf + e.SqlDbCode, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As InvalidOperationException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>非法操作,连接数据库出错<span lang="EN-US">: " + vbCrLf + vbCrLf + e.Message + vbCrLf + vbCrLf + e.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Catch e As Exception</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US"> MsgBox("</span>异常操作,连接数据库出错<span lang="EN-US">: " + vbCrLf + vbCrLf + e.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)</span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> Finally</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> End Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3"> End Sub</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">End Class</span><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: "Calibri","sans-serif";"><p></p></span></font></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #1f497d; FONT-FAMILY: "Calibri","sans-serif";"><p> </p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #1f497d; FONT-FAMILY: "Calibri","sans-serif";"><p> </p></span></p> 好长啊,近来顶一下 进来看一下下
页:
[1]