【发布时间】:2019-07-30 05:43:40
【问题描述】:
Imports System.Data.OleDb
Imports System.Data
Public Class Form1
Dim connection As New OleDbConnection(My.Settings.dataConnectionString)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = Nothing Or TextBox2.Text = Nothing Then
MsgBox("Enter credentials ", MsgBoxStyle.Exclamation)
Else
If connection.State = ConnectionState.Closed Then
connection.Open()
End If
Dim cmd As New OleDbCommand("select count (*) from log in where last name=? and ID=?", connection)
cmd.Parameters.AddWithValue("@1", OleDbType.VarChar).Value = TextBox1.Text
cmd.Parameters.AddWithValue("@2", OleDbType.VarChar).Value = TextBox2.Text
Dim count = Convert.ToInt64(cmd.ExecuteScalar())
If (count > 0) Then
MsgBox("log in succeed", MsgBoxStyle.Information)
Else
MsgBox("account not found check credentials", MsgBoxStyle.Critical)
End If
End If
End Sub
End Class
【问题讨论】:
-
Dim count = Convert.ToInt64(cmd.ExecuteScalar()) 错误
-
顺便说一句,Int64 是 vb.net 中的 Long。 CLng 应该可以工作。
标签: vb.net