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
yash patel
1.1k
283
21k
connection.string is showing closed
Dec 5 2020 7:41 AM
below wis the code
everything is fine model state is also getting treue but when it is checking the connection string at that time why the connection string is showing closed.
I want to insert details using stored procedure.
static string ConnectionString = "Data Source=DESKTOP-O4FO06T/SQL2017;Initial Catalog=practical;Integrated Security=True";
public static int InsertUserDetails( UserModel obj )
{
int rowAffected = 0;
using (IDbConnection con = new SqlConnection(ConnectionString))
{
i
f (con.State == ConnectionState.Closed)
con.Open();
DynamicParameters parameters = new DynamicParameters();
parameters.Add("@Name", obj.Name, DbType.String);
parameters.Add("@Gender", obj.Gender, DbType.String);
parameters.Add("@Address", obj.Address, DbType.String);
parameters.Add("@Mobile", obj.Mobile, DbType.String);
rowAffected = con.Execute("InsertUserDetails", parameters, commandType: CommandType.StoredProcedure);
}
return rowAffected;
}
Reply
Answers (
2
)
How to Create Chart with huge data
I have enum and attached numbers to it how to retrieve number