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
Ekrem Tapan
NA
967
81.2k
SQL insert and Update
Jun 7 2016 3:08 AM
hi everyone, when i want to insert sql some value i have a getting
“executenonquery connection property has not been initialized” error.
but i dont know why ?
everything is clearly code is below
anyone have a any idea for this trouble ?
for
(
int
i = 0; i <
this
._blocks.Count; i++)
{
if
(
this
._blocks[i].Visible && !
string
.IsNullOrEmpty(
this
._blocks[i].Year))
{
string
constr = ConfigurationManager.AppSettings[
"ConnInfo"
];
using
(SqlConnection con =
new
SqlConnection(constr))
{
string
sql =
string
.Format(@"IF EXISTS (SELECT * FROM INDUS_OVER_STAT WHERE YEARS = {0}) UPDATE INDUS_OVER_STAT
SET
VAL_1 = {1},
VAL_2 = {2},
VAL_3 = {3},
TARGET_SID =
'{4}'
WHERE YEARS = {0}
ELSE
INSERT INDUS_OVER_STAT(TARGET_SID, YEARS,VAL_1,VAL_2,VAL_3)
VALUES (
'{4}'
, {0},{1},{2},{3})",
this
._blocks[i].Year,
this
._blocks[i].MS,
this
._blocks[i].BNU,
this
._blocks[i].Emp,
this
._groupsSId);
using
(SqlCommand cmd =
new
SqlCommand(sql))
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
}
Reply
Answers (
4
)
Export Excel file and Pdf file of viewmodel in mvc5
how to find user control page in accordian code behind