'================================================================
'过程名称:ShowDataTable
'输入参数:SQL 是用来传入sql语句
' objTable 是传入DataTable
' Type 是传入是文本命令还是存储过程,(预留的还没有用)
' MsgStr 是传入再没有数据是提示的信息
'输出参数:无
'目 的:此过程填充DataTable
'原 作 者:刘晓航
'创建时间:2003.12.10
'修 改 者:刘晓航
'修改时间:2003.12.10
'================================================================
Public Sub ShowDataTable(ByVal SQL As String, ByVal objTable As DataTable, Optional ByVal Type As String = "1", Optional ByVal MsgStr As String = "A")
Dim objAd As New OleDbDataAdapter
If objconn.State = ConnectionState.Closed Then
objconn.Open()
End If
objAd.SelectCommand = New OleDbCommand
objAd.SelectCommand.Connection = objconn
Try
If Type = "1" Then '1表示SQL 文本命令
objAd.SelectCommand.CommandType = CommandType.Text
objAd.SelectCommand.CommandText = SQL
objAd.Fill(objTable)
Else '表示是存储过程
End If
If objTable.Rows.Count < 1 Then
If MsgStr = "A" Then
MsgBox("数据库中无相关记录!", , "系统提示")
ElseIf MsgStr = "False" Then
Exit Try
Else
MsgBox(MsgStr, , "系统提示")
End If
End If
Catch ex As Exception
MsgBox("数据库中无相关记录!", , "系统提示")
End Try
End Sub