sean-keys
asked on
Using getDate MSSQL function in C# code.
Im new to SQL/c#. Here is what I'm trying to do.
strSQL = "INSERT t_customers VALUES (" +
PrepareStr(txt_first_name. Text) + "," +
PrepareStr(txt_last_name.T ext) + "," +
PrepareStr(txt_user_name.T ext) + "," +
PrepareStr(txt_password.Te xt) + "," +
PrepareStr(txt_address.Tex t) + "," +
Next I want to include getDate, so I can get the date from the SQL server and insert it into the next field in the table, but I'm not sure how to go about doing this.
Thanks in advance,
Sean
strSQL = "INSERT t_customers VALUES (" +
PrepareStr(txt_first_name.
PrepareStr(txt_last_name.T
PrepareStr(txt_user_name.T
PrepareStr(txt_password.Te
PrepareStr(txt_address.Tex
Next I want to include getDate, so I can get the date from the SQL server and insert it into the next field in the table, but I'm not sure how to go about doing this.
Thanks in advance,
Sean
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
An advice, use String.Format to make code more readable and easy to update
strSQL = String.Format("INSERT t_customers VALUES ({0}, {1}, {2}, {3}, {4} , GETDATE())",PrepareStr(txt _first_nam e.Text), PrepareStr(txt_last_name.T ext), PrepareStr(txt_user_name.T ext), PrepareStr(txt_password.Te xt), PrepareStr(txt_address.Tex t));
Look for String.Format on MSDN
strSQL = String.Format("INSERT t_customers VALUES ({0}, {1}, {2}, {3}, {4} , GETDATE())",PrepareStr(txt
Look for String.Format on MSDN
PrepareStr(txt_address.Tex