Inside of method
btnSave_Click
, you need to:
1. Open
SqlConnection[
^]
2. Create
SqlCommand[
^]
3.
Add parameters[
^] to the command
4.
ExecuteNonQuery[
^]
As OriginalGriff already wrote, you need to use proper data type:
DateTime
, instead of text (
string
).
public void btnSave_Click(DateTime dob)
{
int retVal = 0;
using(SqlConnection connection = new SqlConnection("connection_string_here"))
{
connection.Open();
using(SqlCommand cmd = new SqlCommand("command_text_here", connection))
{
cmd.Parameters.Add(DataAccess.CreateParameter(cmd, "DateofBirth", DbType.DateTime, dob));
retVal = cmd.ExecuteNonQuery();
}
}
if(retVal>0)
{
}
else
{
}
}