Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Answers
The variable name '@logo' has already been declared. c#
Jyoti Jodha
7y
183
1
Reply
The variable name '@logo' has already been declared. Variable names must be unique within a query batch or stored procedure. in windows form c#
cmd =
new
SqlCommand(
"insert into cmpny_dtl(c_name,adrs,c_phone,,logo ,state_id ) values(@c_name,@adrs,@c_phone,@state_id )"
, con);
con.Open();
cmd.Parameters.AddWithValue(
"@c_name"
, CmpnyName_txt.Text);
cmd.Parameters.AddWithValue(
"@adrs"
, Adrs_txt.Text);
cmd.Parameters.AddWithValue(
"@c_phone"
, CmpnyPhone_txt.Text);
cmd.Parameters.AddWithValue(
"@logo"
,
"@logo"
);
cmd.Parameters.AddWithValue(
"@state_id"
, STATE_comboBox.SelectedValue);
if
(pictureBox1.Image !=
null
)
{
MemoryStream ms =
new
MemoryStream();
pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte
[] photo = ms.ToArray();
cmd.Parameters.AddWithValue(
"@logo"
, photo);
}
else
{
cmd.Parameters.AddWithValue(
"@logo"
, (pictureBox1.Image ==
null
) ? (
object
)DBNull.Value : pictureBox1.Image).SqlDbType = SqlDbType.Image;
}
int
k = cmd.ExecuteNonQuery();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show(
"Record Inserted Successfully"
);
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Browser URL Encryption and Decryption
Textbox validation for amount