VB中MessageBox和MsgBox 默認(rèn)是不加聲音的,只有你設(shè)置了,才會發(fā)出聲音。
坪山網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),坪山網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為坪山近1000家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個售后服務(wù)好的坪山做網(wǎng)站的公司定做!
如
'無聲音
MessageBox.Show("Hello?World",?"Windows")
'有聲音
MessageBox.Show("Hello?World",?"Windows",?MessageBoxButtons.OK,?MessageBoxIcon.Warning)
開始--設(shè)置-控制面板-聲音和音頻設(shè)備-聲音-程序出錯然后你可以把程序錯誤的聲音關(guān)閉了。
可以在客戶端注入腳本,如:
ClientScript.RegisterStartupScript(typeof(Page), "ScriptKey", "script type=\"text/javascript\" language=\"javascript\"window.alert("+你的異常信息+");/script");
還有就是捕獲異??梢杂?/p>
try
{
}
catch(Exception e)
{
throw new Exception(e.Message);
}
Private Function getAccessConnection() As OleDbConnection
'整體思路應(yīng)該是:連接數(shù)據(jù)庫-運用適配器運行查詢詞句-將查詢結(jié)果填充到數(shù)據(jù)集-以數(shù)據(jù)集為數(shù)據(jù)源,在DataGrid中顯示。
Dim dbConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=|DataDirectory|\Resources\mag.mdb;Persist Security Info=true"
'連接字符串,Provider,連接引擎,可以死記,OLEDB就用這處,Data Source,設(shè)置數(shù)據(jù)庫的位置。
Dim dbConnection As OleDbConnection = New OleDbConnection(dbConnectionString)
Try
dbConnection.Open()
Catch Ex As Exception
’MsgBox(Err.Description)
End Try
Return dbConnection
End Function
private Sub fillDataGridView()
Dim sqlStr As String = "select * from Table"
Dim DataAdapter As New OleDbDataAdapter
Dim dataSet As New DataSet
Dim DataGridView As New DataGridView
Dim dbConnection As OleDbConnection = getAccessConnection()
If dbConnection.State.ToString = "Closed" Then
MsgBox(Chr(13) " access 數(shù)據(jù)庫連接失敗 " Chr(13), , "警告")
Exit Sub
End If
DataAdapter.SelectCommand = New OleDbCommand(sqlStr,dbConnection)
'用數(shù)據(jù)適配器進行查詢
Try
DataAdapter.Fill(dataSet,"Table") '將查詢結(jié)果填充到數(shù)據(jù)集Dataset,有點像VB中的記錄集recordset
DataGridView.DataSource = dataSet.Tables("Table").DefaultView '將數(shù)據(jù)集的內(nèi)容在表格中顯示出來
Catch Ex As Exception
MsgBox(Err.Description)
Finally
dataSet.Dispose
DataAdapter.Dispose
dbConnection.Close
dbConnection.Dispose
End Try
End Sub