VB.NET的 把重点的语句注释下就行了

[复制链接]
查看11 | 回复1 | 2009-1-6 09:02:48 | 显示全部楼层 |阅读模式
(1)Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click

Dim schclass As String = Trim(txtClass.Text)

Dim selestr As String

If schclass"" Then

selestr = "班级='" & schclass & "'"

Else

MsgBox("请输入班级名称", 64, "提示")
‘ 显示保存成功提示信息

End If

Dim dvresult As DataView = DataSet11.学生成绩.DefaultView

dvresult.Sort = "学号"

dvresult.RowFilter = selestr

dvresult.RowStateFilter = DataViewRowState.CurrentRows

DataGrid1.DataSource = dvresult
End Sub
(2)2. 程序代码如下:
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
If txtUserName.Text = "" Or txtPass.Text = "" Then

Response.Write("")

Exit Sub
End If
Dim mycon As New OleDbConnection
Dim mycmd As New OleDbCommand
Dim reader As OleDbDataReader
mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath("Msg.mdb")
mycon.Open()
mycmd.Connection = mycon
mycmd.CommandType = CommandType.Text
mycmd.CommandText = "Select * from myuser Where 用户名='" & txtUserName.Text & "'" & " and 密码='" & txtPass.Text & "'"
reader = mycmd.ExecuteReader()
If reader.Read = False Then

Response.Write("")
Else

Session("username") = reader("用户名")

Response.Redirect("lwmsg.aspx")
End If
reader.Close()
mycon.Close()
End Sub

回复

使用道具 举报

千问 | 2009-1-6 09:02:48 | 显示全部楼层
'''两段程序就是利用.net的连接对象的功能来完成登录的实例Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click 'start按钮触发的函数 Dim schclass As String = Trim(txtClass.Text) ‘将txtClass里文本赋值给变量schclass Dim selestr As String ’提示用户txtClass文本框不能为空 If schclass"" Then selestr = "班级='" & schcla...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行