我是新手,我想问一下怎么使用数据库?还有怎么使用dos里的ping命令。

watercat1000 2004-05-05 08:42:30
我把一批ip地址放在数据库里,我想使用ping命令,把返回结果放在另一个表里。
...全文
52 3 点赞 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
chenyu001 2004-05-05

Imports System.Data
Imports System.Drawing
Imports System.Data.OleDb

Public Class MconnfromDB

'************************************
'定义的一些公共变量
'************************************
Private Shared DBName As String '数据库名称
Private Shared ServerName As String '服务器名称
Private Shared WorkStation As String '工作站名称
Private Shared DBPws As String '数据库密码

Private Connstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\data\student.mdb;Persist Security Info=False;;Jet OLEDB:Database Password=576189"
Private Connectstr As String = Connstr
Private da As OleDb.OleDbDataAdapter
Private Dataconnection As OleDb.OleDbConnection
Private ds As DataSet

Private Sub OpenConn()
Try
If Dataconnection Is Nothing Then
Dataconnection = New OleDb.OleDbConnection
End If
If Dataconnection.State = ConnectionState.Closed Then
Dataconnection.ConnectionString = Connectstr
Dataconnection.Open()
End If
Catch e As Exception
studentException.Save(e, "")
End Try
End Sub
Public Sub CloseConn()
Try
If Dataconnection.State = ConnectionState.Open Then
Dataconnection.Close()
End If
Catch e As Exception
studentException.Save(e, "")
End Try
End Sub
Public Function OpenTransConn() As OleDb.OleDbConnection
Dim tmpConn As OleDb.OleDbConnection
Try
tmpConn = New OleDb.OleDbConnection
tmpConn.ConnectionString = Connectstr
tmpConn.Open()
Catch e As Exception
studentException.Save(e, "")
End Try
Return tmpConn
End Function

Public Sub CloseTransConn(ByVal conn As OleDb.OleDbConnection)
Try
If conn.State = ConnectionState.Open Then
conn.Close()
End If
Catch e As Exception
studentException.Save(e, "")
End Try
End Sub

Public Function GetDataFromDB(ByVal sqlstr As String) As DataSet
Try
OpenConn()
da = New OleDb.OleDbDataAdapter(sqlstr, Dataconnection)
ds = New DataSet
ds.Clear()
da.Fill(ds)
da = Nothing
CloseConn()
Catch e As Exception
studentException.Save(e, sqlstr)
Finally
CloseConn()
End Try
If ds.Tables(0).Rows.Count >= 0 Then '如果ds只是new dataset ,那这个地方就会出错?如何改进!
Return ds
Else
Return Nothing
End If
End Function

'*********************************************
'定义一个数据操作成功标志的函数
'*********************************************
Public Function UpdateDataBase(ByVal sqlstr As String) As Boolean
Try
OpenConn()
Dim cmdtables As OleDb.OleDbCommand = New OleDb.OleDbCommand(sqlstr, Dataconnection)
cmdtables.CommandType = CommandType.Text
cmdtables.ExecuteNonQuery()
cmdtables = Nothing
CloseConn()
Catch e As Exception
studentException.Save(e, sqlstr)
Return False
End Try
Return True
End Function

End Class

  • 打赏
  • 举报
回复
watercat1000 2004-05-05
我用的是vb.net怎么给我的里面是#c的阿
  • 打赏
  • 举报
回复
wangsaokui 2004-05-05
使用数据库看
www.connectionstrings.com

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/vbcon/html/vbwlkwalkthroughdisplayingdatafromsingletableinwindowsform.htm

ping看这个
http://expert.csdn.net/Expert/topic/2864/2864130.xml?temp=.3010218
  • 打赏
  • 举报
回复
相关推荐
发帖
VB
加入

1.6w+

社区成员

VB技术相关讨论,主要为经典vb,即VB6.0
申请成为版主
帖子事件
创建了帖子
2004-05-05 08:42
社区公告
暂无公告