問題應(yīng)該出在你的查詢語(yǔ)句的結(jié)果沒有值,你用你的查詢語(yǔ)句到SQL中是否有返回值?記得加上你的條件,另外,你語(yǔ)句里這一句是多余的.Dim s As Object = sComm.ExecuteScalar 以下語(yǔ)句測(cè)試正常 Dim myCn As New SqlClient.SqlConnection Try myCn.ConnectionString = sConnString myCn.Open() Dim mySQL As String = "SELECT * FROM ygzl" Dim sComm As New SqlClient.SqlCommand(mySQL, myCn) If sComm.ExecuteScalar Then Dim User_MainForm As New Form1 User_MainForm.Show() Else MsgBox("用戶名或密碼不正確,請(qǐng)重試!") End If Catch ex As Exception MsgBox(ex.Message) Finally myCn.Close() '關(guān)閉連接 End Try
創(chuàng)新互聯(lián)建站是一家專業(yè)提供光山企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、H5技術(shù)、小程序制作等業(yè)務(wù)。10年已為光山眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進(jìn)行中。
Private Sub SendBlogTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendBlogTimer.Tick
Dim textboxUserId As HtmlElement
Dim textboxPassword As HtmlElement
Dim buttonSubmit As HtmlElement
textboxUserId = SendBlogBrowser.Document.All("username")'獲取用戶名輸入框
textboxPassword = SendBlogBrowser.Document.All("password")'獲取密碼輸入框
buttonSubmit = SendBlogBrowser.Document.All("btnLogin")'獲取登陸按鈕
textboxUserId.SetAttribute("value","用戶名")'給用戶名輸入框賦值
textboxPassword.SetAttribute("value","密碼")'給密碼框賦值
buttonSubmit.InvokeMember("click")’執(zhí)行登陸按鈕的單擊
End Sub
其中的SendBlogBrowser為WebBrowser控件
哈哈簡(jiǎn)單哪
第一步:登陸網(wǎng)頁(yè)代碼
第二步:登陸以后判斷是否登陸成功
有兩種方法:1.獲取網(wǎng)頁(yè)代碼,判斷網(wǎng)頁(yè)字符有無”登陸成功”字樣
源代碼:
2.就是判斷網(wǎng)頁(yè)是否跳轉(zhuǎn)到了某一頁(yè)
源代碼:
兩種方法結(jié)合起來用,可以判斷網(wǎng)頁(yè)是否無法連接
Private Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) Handles Button Click
If TextBox Text = Or TextBox Text = Then
Label Text = 請(qǐng)確認(rèn)您的輸入!
Return
End If
Dim sql As String = select * from pwd where stu_id=@stu_id and pwd=@pwd
Dim m As SqlCommand = New SqlCommand(sql conn)
m Parameters Add(New SqlParameter( @stu_id SqlDbType Int ))
m Parameters( @stu_id ) Value = TextBox Text
m Parameters Add(New SqlParameter( @pwd SqlDbType Char ))
m Parameters( @pwd ) Value = TextBox Text
Dim dr As SqlDataReader
conn Open()
dr = m ExecuteReader
If dr Read Then
Session( stu_id ) = TextBox Text
dr Close()
m Cancel()
Dim sql_ As String = update stu_base set point=point+ where stu_id=@stu_id
m = New SqlCommand(sql_ conn)
m Parameters Add(New SqlParameter( @stu_id SqlDbType Int ))
m Parameters( @stu_id ) Value = Session( stu_id )
m ExecuteNonQuery()
m Cancel()
Response Redirect( detail aspx?stu_id= Session( stu_id ) )
Else
Label Text = 您還沒有注冊(cè)或賬號(hào)密碼錯(cuò)誤
End If
End Sub
Private Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) Handles Button Click
TextBox Text =
TextBox Text =
lishixinzhi/Article/program/net/201311/13960