TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gimeesha Gamage
NA
1
1.9k
C# simple logging page Desktop application
Apr 4 2013 12:24 AM
i'm new for programming. I designed simple loging page.code as below.
SqlConnection
con =
new
SqlConnection
();
SqlCommand
cmd =
new
SqlCommand
(
"select * from loginp where username=@u and pasword=@p"
, con);
if
(con.State ==
ConnectionState
.Closed)
con.open();
cmd.Parameters.Add(
"@u"
,
SqlDbType
.VarChar, 50).Value = textBox1_username.Text;
cmd.Parameters.Add(
"@p"
,
SqlDbType
.VarChar, 50).Value = textBox1_passowrd.Text;
SqlDataReader
dr = cmd.ExecuteReader();
if
((dr.Read() ==
true
))
{
MessageBox
.Show(
"Welcome User"
);
Form1
obj =
new
Form1
();
obj.Show();
this
.Hide();
}
else
MessageBox
.Show(
"invalid Username and Passowrd"
);
dr.Close();
But I received error message as below.
Error 1 'System.Data.SqlClient.SqlConnection' does not contain a definition for 'open' G:\pro\new\new\Form1.cs 33 21 new
plz advice me to how to reslove it
Reply
Answers (
3
)
ComboBox and textbox
Changing value of control defined in HTML file