VB中MessageBox和MsgBox 默认是不加声音的,只有你设置了,才会发出声音。
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名申请、网页空间、营销软件、网站建设、宣汉网站维护、网站推广。
如
'无声音
MessageBox.Show("Hello World", "Windows")
'有声音
MessageBox.Show("Hello World", "Windows", MessageBoxButtons.OK, MessageBoxIcon.Warning)
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
可以在客户端注入脚本,如:
ClientScript.RegisterStartupScript(typeof(Page), "ScriptKey", "script type=\"text/javascript\" language=\"javascript\"window.alert("+你的异常信息+");/script");
还有就是捕获异常可以用
try
{
}
catch(Exception e)
{
throw new Exception(e.Message);
}