xynl 发表于 2007-10-21 11:43:26

发布后联不上数据库!!!

<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">&nbsp;</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">&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theConnection.Open()</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;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">&nbsp;</font></p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As NullReferenceException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As TransactionException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As InvalidOperationException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As Exception</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Finally</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theConnection.Open()</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span lang="EN-US" style="FONT-SIZE: 14pt; COLOR: red;">&nbsp;SQLCA.BindConnection()<p></p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As NullReferenceException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As TransactionException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As InvalidOperationException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As Exception</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Finally</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp; </font></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.AutoCommit = True</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As NullReferenceException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As TransactionException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As InvalidOperationException</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch e As Exception</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font size="3"><font face="宋体"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Finally</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Try</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US"><font face="宋体" size="3">&nbsp; &nbsp;&nbsp;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: &quot;Calibri&quot;,&quot;sans-serif&quot;;"><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: &quot;Calibri&quot;,&quot;sans-serif&quot;;"><p>&nbsp;</p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #1f497d; FONT-FAMILY: &quot;Calibri&quot;,&quot;sans-serif&quot;;"><p>&nbsp;</p></span></p>

lovelyni 发表于 2007-12-19 21:56:47

好长啊,近来顶一下

lovelyni 发表于 2007-12-19 21:57:12

进来看一下下
页: [1]
查看完整版本: 发布后联不上数据库!!!

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com