• λ我爱Aspx >> Asp.Net >> SqlConnection.Open()
  • SqlConnection.Open()

  • :aspxer  Դ:csdn  :2007-7-6 2:51:50  ؼ:sql
  • End Sub

    第2楼. 由 zzy1254 于 2007-4-17 8:13:56 发表

    根据我遇到的情况,这里面的对象还存在,你可以使用try 块去控制它,

    Dim SqlConnection1 As System.Data.SqlClient.SqlConnection

    Dim SqlCommand1 As System.Data.SqlClient.SqlCommand

    try

    sqlconnection1 = new sqlclient.sqlconnect

    SqlConnection1.ConnectionString = strModConnectionString

    sqlcommand1= new sqlclient.sqlcommand

    SqlCommand1.Connection = SqlConnection1

    SqlConnection1.Open()

    SqlCommand1.CommandText = "Select count(*) from Table"

    Msgbox "SqlCommand1.ExecuteScalar()"

    Catch ex As Exception

    msgbox ex.massage

    finally

    SqlCommand1=Nothing

    SqlConnection1.Close()

    SqlConnection1=Nothing

    end try

    这样可以在发生错误后,将连接对象释放掉

    第3楼. 由 cfreez 于 2007-4-17 8:21:18 发表

    只需要SqlConnection1.Close()就行了

    如果是2005,用Using conn as new sqlconnection()

    Ҷƪл˵?
  • һƪ各位高手帮下菜鸟好么,一个关于树的问题.
    һƪ用C#编写读取和添加xml数据