मैं अपने डेटाबेस के लिए Postgresql का उपयोग कर रहा हूं, मैं एक ऐप बनाना चाहता हूं जहां उपयोगकर्ता अपना खाता लॉगिन करता है, मेरे पास यह तर्क है, और मुझे यह त्रुटि मिल रही है System.NullReferenceException: 'ऑब्जेक्ट संदर्भ किसी ऑब्जेक्ट के उदाहरण पर सेट नहीं है .' मुझे यह त्रुटि क्यों मिल रही है?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim Username = Username_TextBox1.Text
Dim Password = Password_TextBox2.Text
Dim dt As New DataTable
Dim ds = New DataSet
Dim i As Integer
Try
Using MyCon As New Odbc.OdbcConnection("Driver={PostgreSQL ANSI};database=YouthRecord;server=localhost;port=5432;uid=postgres;sslmode=disable;readonly=0;protocol=7.4;User ID=*****;password=*****;"),
cmd As New Odbc.OdbcCommand("SELECT * FROM YouthApp_tableuser WHERE `username` " & "='" & Username & "' and " & "password='" & Password & "'", MyCon)
If ds.Tables("YouthApp_tableuser").Rows.Count > 0 Then
For i = 0 To ds.Tables("YouthApp_tableuser").Rows.Count - 1
Username = ds.Tables("YouthApp_tableuser").Rows(i).Item(1).ToString
Password = ds.Tables("YouthApp_tableuser").Rows(i).Item(2).ToString
Next
If (Username = Username_TextBox1.Text And Password = Password_TextBox2.Text) Then
Username = ""
Password = ""
MainForm.Show()
Me.Hide()
Else
MsgBox("Invalid User! Please Enter Correct User Name and Password.", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalid!")
Username = ""
Password = ""
End If
End If
MyCon.Open()
dt.Load(cmd.ExecuteReader)
End Using
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Catch ex As Exception
End Try
यह त्रुटि है
अपडेट करें
Try
Using MyCon As New Odbc.OdbcConnection("Driver={PostgreSQL ANSI};database=YouthRecord;server=localhost;port=5432;uid=******;sslmode=disable;readonly=0;protocol=7.4;User ID=*****;password=*****;"),
cmd As New Odbc.OdbcCommand("SELECT id, username, password FROM ""YouthApp_tableuser"" where username='" & Username & "' and password='" & Password & "' ", MyCon)
MyCon.Open()
dt.Load(cmd.ExecuteReader)
If ds.Tables("YouthApp_tableuser").Rows.Count > 0 Then
If (Username = Username_TextBox1.Text And Password = Password_TextBox2.Text) Then
Username = ""
Password = ""
MainForm.Show()
Me.Hide()
Else
MsgBox("Invalid User! Please Enter Correct User Name and Password.", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalid!")
Username = ""
Password = ""
End If
End If
End Using
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
मुझे समान त्रुटि मिली
0
user12951147
26 अक्टूबर 2020, 15:32
1 उत्तर
सबसे बढ़िया उत्तर
Try
Using MyCon As New Odbc.OdbcConnection("Driver={PostgreSQL ANSI};database=YouthRecord;server=localhost;port=5432;uid=*****;sslmode=disable;readonly=0;protocol=7.4;User ID=*****;password=*****;"),
cmd As New Odbc.OdbcCommand("SELECT id, username, password FROM ""YouthApp_tableuser"" where username='" & Username & "' and password='" & Password & "' ", MyCon)
MyCon.Open()
dt.Load(cmd.ExecuteReader)
If dt.Rows.Count > 0 Then
If (Username = Username_TextBox1.Text And Password = Password_TextBox2.Text) Then
Username = ""
Password = ""
MainForm.Show()
Me.Hide()
End If
Else
MsgBox("Invalid User! Please Enter Correct User Name and Password.", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalid!")
Username = ""
Password = ""
End If
End Using
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
0
kaito
26 अक्टूबर 2020, 17:11
संबंधित सवाल
नए सवाल
vb.net
Visual Basic.NET (VB.NET) एक बहु-प्रतिमान, प्रबंधित, प्रकार-सुरक्षित, ऑब्जेक्ट-उन्मुख कंप्यूटर प्रोग्रामिंग भाषा है। C # और F # के साथ, यह .NET फ्रेमवर्क को लक्षित करने वाली मुख्य भाषाओं में से एक है। VB.NET को Microsoft के Visual Basic 6 (VB6) के विकास के रूप में देखा जा सकता है लेकिन Microsoft .NET फ्रेमवर्क पर लागू किया जा सकता है। VB6, VBA या VBScript प्रश्नों के लिए इस टैग का उपयोग न करें।