C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

LOGIN Page


Posted Date: 07 Oct 2008      Posted By: Kamaraj      Member Level: Silver     Points: 1   Responses: 7



I am Execute the Following Code but it was Shown :"Object reference not set to an instance of an object". Error...
Dim cs As String = "Data Source=SERVER;initial catalog=master;user id=sa"
Dim Con As New SqlConnection(cs)
Dim da As New SqlDataAdapter
If TxtUsername.Text = "" And txtpassword.Text = "" Then
MessageBox.Show("Please enter username and password")

ElseIf TxtUsername.Text = "" Then
MessageBox.Show("Please enter username")
ElseIf txtpassword.Text = "" Then
MessageBox.Show("Please enter Password")

ElseIf da.SelectCommand.CommandText = "SELECT * FROM tbllogin WHERE username = '+ TxtUsername.Text.trim +' and pass = '+ txtpassword.Text.Trim +' " Then
End If





Responses

Author: Jigar Joshi    07 Oct 2008Member Level: GoldRating: 1 out of 5     Points: 1

which line?


Author: Kamaraj    07 Oct 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

in the line of
da.SelectCommand.CommandText = "SELECT * FROM tbllogin WHERE username = '+ TxtUsername.Text.trim +' and pass = '+ txtpassword.Text.Trim +'



Author: sappi    07 Oct 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

"SELECT * FROM tbllogin WHERE username ='"+TxtUsername.Text.trim +"','"+txtpassword.Text.Trim +"'";


Author: Abhi    07 Oct 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

da.SelectCommand.CommandText = "SELECT * FROM tbllogin WHERE username = '+ TxtUsername.Text.trim +' and pass = '+ txtpassword.Text.Trim +'


Author: Kamaraj    07 Oct 2008Member Level: SilverRating: 1 out of 5     Points: 1

it is also Shown the Error...

Some Query i am Run in the ISQLW
it shown nohting....
but just i call Select * from tbllogin it was shown?



Author: santosh    07 Oct 2008Member Level: BronzeRating: 3 out of 53 out of 53 out of 5     Points: 3

hi just try this

Dim cs As String = "Data Source=SERVER;initial catalog=master;user id=sa"
Dim Con As New SqlConnection(cs)
Dim da As New SqlDataAdapter
If TxtUsername.Text = String.Empty or txtpassword.Text = String.Empty Then
MessageBox.Show("Please enter username and password")

ElseIf da.SelectCommand.CommandText = "SELECT * FROM tbllogin WHERE username = '+ TxtUsername.Text.trim() +' and pass = '+ txtpassword.Text.Trim() +' " Then
End If




rock on.....................
santosh



Author: Abhi    07 Oct 2008Member Level: DiamondRating: 3 out of 53 out of 53 out of 5     Points: 3

Dim cs As String = "Data Source=SERVER;initial catalog=master;user id=sa"
Dim Con As New SqlConnection(cs)
Dim da As New SqlDataAdapter
If TxtUsername.Text = "" And txtpassword.Text = "" Then
MessageBox.Show("Please enter username and password")

ElseIf TxtUsername.Text = "" Then
MessageBox.Show("Please enter username")
ElseIf txtpassword.Text = "" Then
MessageBox.Show("Please enter Password")

ElseIf da.SelectCommand.CommandText = "SELECT * FROM tbllogin WHERE username = '+ TxtUsername.Text.trim() +' and pass = '+ txtpassword.Text.Trim() +' " Then
End If

perhaps you are missing Trim() instead of Trim

Thanks and Regards,
Abhay



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : using interface in c# winforms
Previous : how to store image in database in 3 tire architecture
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use