-1
似乎無法確定在此錯誤中使用的代碼。無法將'System.Data.SqlClient.SqlConnection'類型的錯誤值轉換爲'字符串'
它指出在此行暗淡Flag_DR作爲SqlDataReader的= Flag_com.ExecuteReader
非常感謝
Private Sub txt_Password_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txt_Password.KeyDown
If e.KeyCode = Keys.Enter Then
If txt_Username.Text = "hospital" And txt_Password.Text = "user" Then
Me.Hide()
Dim r0 As String
Dim Flag_constr As New SqlConnection("Data Source=(localdb)\Projects;Initial Catalog=MasterDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False")
'Dim Fill_Textbox_cmdstr As String = "select Regno,Name,Age,Address,Phone,Checkupdate,Checkuptime,Disease,Bloodgroup,Doctor,Remarks from clinicpatients where Regno=1"
Dim Flag_cmdstr As String = "select * from flag"
Dim Flag_con As New SqlConnection("Data Source=(localdb)\Projects;Initial Catalog=MasterDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False")
Dim Flag_com As New SqlCommand(Flag_cmdstr, Flag_con)
Flag_con.Open()
Dim Flag_DR As SqlDataReader = Flag_com.ExecuteReader
While Flag_DR.Read
r0 = Flag_DR(0)
End While
Flag_con.Close()
If r0 = 0 Then
Dim objfrmBed As New frmBed()
objfrmBed.Show()
ElseIf r0 = 1 Then
Dim objfrmMain As New frmMain()
objfrmMain.Show()
End If
你已經用'Flag_constr'創建了一個使用實際連接字符串的連接,第二個'Flag_con'是多餘的。你的重複變量名稱讓你感到困惑 – Plutonix
你的編輯完全改變了這個問題。你列出的錯誤不可能來自你所說的行。另外它使@Plutonix評論無意義。 –
我已回滾您的編輯。答案發布後,您無法完全改變問題:主體不再與標題匹配,並且使發佈的答案失效。答案解決了你原來的問題,所以要親切並接受答案並繼續前進。 – Plutonix