VB中MessageBox和MsgBox 默认是不加声音的,只有你设置了,才会发出声音。
坪山网站建设公司成都创新互联,坪山网站设计制作,有大型网站制作公司丰富经验。已为坪山近1000家提供企业网站建设服务。企业网站搭建\成都外贸网站建设要多少钱,请找那个售后服务好的坪山做网站的公司定做!
如
'无声音
MessageBox.Show("Hello World", "Windows")
'有声音
MessageBox.Show("Hello World", "Windows", MessageBoxButtons.OK, MessageBoxIcon.Warning)
开始--设置-控制面板-声音和音频设备-声音-程序出错然后你可以把程序错误的声音关闭了。
可以在客户端注入脚本,如:
ClientScript.RegisterStartupScript(typeof(Page), "ScriptKey", "script type=\"text/javascript\" language=\"javascript\"window.alert("+你的异常信息+");/script");
还有就是捕获异常可以用
try
{
}
catch(Exception e)
{
throw new Exception(e.Message);
}
Private Function getAccessConnection() As OleDbConnection
'整体思路应该是:连接数据库-运用适配器运行查询词句-将查询结果填充到数据集-以数据集为数据源,在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,设置数据库的位置。
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 数据库连接失败 " Chr(13), , "警告")
Exit Sub
End If
DataAdapter.SelectCommand = New OleDbCommand(sqlStr,dbConnection)
'用数据适配器进行查询
Try
DataAdapter.Fill(dataSet,"Table") '将查询结果填充到数据集Dataset,有点像VB中的记录集recordset
DataGridView.DataSource = dataSet.Tables("Table").DefaultView '将数据集的内容在表格中显示出来
Catch Ex As Exception
MsgBox(Err.Description)
Finally
dataSet.Dispose
DataAdapter.Dispose
dbConnection.Close
dbConnection.Dispose
End Try
End Sub