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
Meena S
NA
48
4.2k
Must declare scalar variable in login form
May 3 2019 12:19 AM
I am getting error "Must declare scalar variable @uname and @pw". I have tried many methods but its not working. please guide me to find the issue in my belo code.
private
void
button1_Click(
object
sender, EventArgs e)
{
OleDbConnection con =
new
OleDbConnection(@
"Provider=SQLOLEDB;Data Source=DESKTOP\SQLEXPRESS;User ID=sa; Password = pwd; Initial Catalog=database; Integrated secutity=SSPI"
);
con.Open();
OleDbCommand cmd =
new
OleDbCommand(
"select Username,password from login where Username=@uname and password=@pw"
, con);
OleDbDataAdapter da =
new
OleDbDataAdapter(cmd);
cmd.Parameters.Clear();
//cmd.Parameters.AddWithValue("@uname", textBox1.Text);
//cmd.Parameters.AddWithValue("@pw", textBox1.Text);
DataTable dt =
new
DataTable();
da.Fill(dt);
if
(dt.Rows.Count > 0)
{
MessageBox.Show(
"success"
);
}
else
{
MessageBox.Show(
"incorrect"
);
}
con.Close();}
Reply
Answers (
3
)
how to display textbox values in grid view
Need help for clarion learning and development