关于vb.net数据库视频的信息

vb.net数据库操作参考一下下面这段代码就可以了 。
ImportsSystem.Data
'引入数据库操作类命名空间
ImportsSystem.Data.OleDb
'引入ADO.NET操作命名空间
PublicClassFrmModifystInfo
InheritsSystem.Windows.Forms.Form
PublicADOcmdAsOleDbDataAdapter
PublicdsAsDataSet=NewDataSet()
'建立DataSet对象
PublicmytableAsData.DataTable
'建立表单对象
PublicmyrowAsData.DataRow
'建立数据行对象
PublicrownumberAsInteger
'定义一个整型变量来存放当前行数
PublicSearchSQLAsString
PubliccmdAsOleDbCommandBuilder
'======================================================
#Region"Windows窗体设计器生成的代码"
#EndRegion
'======================================================
PrivateSubFrmModifystInfo_Load(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesMyBase.Load
'窗体的载入
【关于vb.net数据库视频的信息】TxtSID.Enabled=False
TxtName.Enabled=False
ComboSex.Enabled=False
TxtBornDate.Enabled=False
TxtClassno.Enabled=False
TxtRuDate.Enabled=False
TxtTel.Enabled=False
TxtAddress.Enabled=False
TxtComment.Enabled=False'设置信息为只读
DimtablenameAsString="student_Info "
SearchSQL="select*fromstudent_Info"
ExecuteSQL(SearchSQL,tablename)'打开数据库
ShowData()'显示记录
EndSub
PrivateSubShowData()
'在窗口中的textbox中显示数据
myrow=mytable.Rows.Item(rownumber)
TxtSID.Text=myrow.Item(0).ToString
TxtName.Text=myrow.Item(1).ToString
ComboSex.Text=myrow.Item(2).ToString
TxtBornDate.Text=Format(myrow.Item(3),"yyyy-MM-dd ")
TxtClassno.Text=myrow.Item(4).ToString
TxtTel.Text=myrow.Item(5).ToString
TxtRuDate.Text=Format(CDate(myrow.Item(6)),"yyyy-MM-dd ")
TxtAddress.Text=myrow.Item(7).ToString
TxtComment.Text=myrow.Item(8).ToString
EndSub
PrivateSubBtFirst_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesBtFirst.Click
'指向第一条数据
rownumber=0
ShowData()
EndSub
PrivateSubBtPrev_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesBtPrev.Click
'指向上一条数据
BtNext.Enabled=True
rownumber=rownumber-1
Ifrownumber0Then
rownumber=0'如果到达记录的首部 , 行号设为零
BtPrev.Enabled=False
EndIf
ShowData()
EndSub
PrivateSubBtNext_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesBtNext.Click
'指向上一条数据
BtPrev.Enabled=True
rownumber=rownumber+1
Ifrownumbermytable.Rows.Count-1Then
rownumber=mytable.Rows.Count-1'判断是否到达最后一条数据
BtNext.Enabled=False
EndIf
ShowData()
EndSub
PrivateSubBtLast_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesBtLast.Click
'指向最后一条数据
rownumber=mytable.Rows.Count-1
ShowData()
EndSub
PrivateSubBtDelete_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesBtDelete.Click
mytable.Rows.Item(rownumber).Delete()'删除记录
IfMsgBox( "确定要删除改记录吗? ",MsgBoxStyle.OKCancel+vbExclamation,"警告 ")=MsgBoxResult.OKThen
cmd=NewOleDbCommandBuilder(ADOcmd)
'使用自动生成的SQL语句
ADOcmd.Update(ds,"student_Info ")
BtNext.PerformClick()
EndIf
EndSub
PrivateSubBtModify_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesBtModify.Click
TxtSID.Enabled=False'关键字段只读
TxtName.Enabled=True'可读写
ComboSex.Enabled=True
TxtBornDate.Enabled=True
TxtClassno.Enabled=True
TxtRuDate.Enabled=True
TxtTel.Enabled=True
TxtAddress.Enabled=True
TxtComment.Enabled=True
EndSub

推荐阅读