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
ahmed elbarbary
638
1.6k
281.7k
Error out parameter must be assigned before control leave cu
Aug 14 2019 2:14 PM
Problem
Error out parameter must be assigned before control leave current method .
function GetInsertStatmentText below return full insert statement as below
INSERT
INTO
master_table(id, branch_id,
name
, address, phone)
VALUES
(@id, @branch_id, @
name
, @address, @phone);
in out paramter i need to return
@id, @branch_id, @
name
, @address, @phone
when i add out parameter to function i get error :
Error out parameter must be assigned before control leave current method
How to solve this error please ?
What I have tried:
public
static
string
GetInsertStatmentText(
string
JsonData,
out
sqp)
{
string
Insert =
""
;
JObject jo = JObject.Parse(JsonData);
JToken m = jo[
"master"
];
string
connectionstring =
"Server=AHMEDSALAH-PC\\SQL2014;Database=Atum;User Id=sa;Password=abc123;"
;
//change connection string
using
(SqlConnection connection =
new
SqlConnection(connectionstring))
{
using
(SqlCommand command =
new
SqlCommand(JsonHelper.GetInsertStatement(m), connection))
{
connection.Open();
List<SqlParameter> lsp = JsonHelper.GetSqlParams(jo[
"master"
]);
foreach
(SqlParameter sqp
in
lsp)
command.Parameters.Add(sqp);
Insert = command.CommandText;
}
}
return
Insert;
}
Reply
Answers (
3
)
pass command line arguments from asp.net web application c#
How to generate parametrized insert statement for details wi