I'm using this code:
public void InsertMember(Member member)
{
string INSERT = "INSERT INTO Members (Name, Surname, EntryDate) VALUES (@Name, @Surname, @EntryDate)";
using (sqlConnection = new SqlConnection(sqlConnectionString_WORK))
{
sqlConnection.Open();
using (SqlCommand sqlCommand = new SqlCommand(INSERT, sqlConnection))
{
sqlCommand.Parameters.Add("@Name", SqlDbType.VarChar).Value = member.Name;
sqlCommand.Parameters.Add("@Surname", SqlDbType.VarChar).Value = member.Surname;
sqlCommand.Parameters.Add("@EntryDate", SqlDbType.Date).Value = member.EntryDate;
sqlCommand.ExecuteNonQuery();
}
}
}
It's not showing any errors or problems at all. Is it wrong if I don't add sqlConnection.Close(); before disposing of it? If yes, why?
Your Answer
0 answers
Hot tools Tags
Hot Questions
What's the right way to decode a string that has special HTML entities in it? [duplicate]
2025-12-30 17:22:40
How to generate a simple popup using jQuery
2025-12-30 17:01:10
Gitlab-CI runner: ignore self-signed certificate
2025-12-30 16:22:08
How to succinctly, portably, and thoroughly seed the mt19937 PRNG?
2025-12-30 16:01:51
What's the difference between size_t and int in C++? [duplicate]
2025-12-30 15:43:32
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
Douyin level price list 1-75
20416
7
20416
7
wifi shows no ip assigned
13574
4
13574
4






