• 0

VB.NET connection problem


Question

I have a problem with my code. below is my code.

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

Dim pwd As String 'to store password entered by user

'Dim md5Hasher As New MD5CryptoServiceProvider

'Dim hashedDataBytes As Byte()

'Dim encoder As New UTF8Encoding

'hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(PasswordTextBox.Text))

Dim cnnFYP As SqlConnection = New SqlConnection

Dim comFYP As SqlCommand = New SqlCommand

Dim paramPwd As SqlParameter

paramPwd = New SqlParameter("@Password", SqlDbType.Binary, 16)

'paramPwd.Value = hashedDataBytes

pwd = PasswordTextBox.Text

Dim paramCount As SqlParameter

paramCount = New SqlParameter("@count", SqlDbType.Int)

paramCount.Direction = ParameterDirection.Output

'Dim strSQL As String = "select DoctorID, NurseID, DoctorPasswords, NursePasswords from DOCTOR, NURSE where DoctorID = @doctorID and NurseID = @nurseID and DoctorPasswords = @doctorpasswords and NursePasswords = @nursepasswords"

Dim strSQL As String = "select @count = COUNT(*) from DOCTOR, NURSE where DoctorID = @doctorID and NurseID = @nurseID and DoctorPasswords = @doctorpasswords and NursePasswords = @nursepasswords"

With comFYP

.Connection = cnnFYP

.CommandText = strSQL

.Parameters.AddWithValue("@doctorID", UsernameTextBox.Text)

.Parameters.AddWithValue("@nurseID", UsernameTextBox.Text)

.Parameters.Add(paramPwd)

.Parameters.Add(paramCount)

End With

cnnFYP.Open() <-- Problem here!!!

comFYP.ExecuteNonQuery()

comFYP.Dispose()

cnnFYP.Dispose()

dr = comFYP.ExecuteReader

If dr.HasRows Then

dr.Close()

Label1.Text = "Welcome"

Else

Label1.Text = "Please re-enter your password"

Label1.Visible = True

End If

cnnFYP.Close()

Me.Close()

End Sub

I try to do a login window. Below is the problem.

lll9tj.jpg

So what is the problem that course this?

Link to comment
https://www.neowin.net/forum/topic/475969-vbnet-connection-problem/
Share on other sites

2 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.