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
karthi geyan
NA
5
10k
Time datatype in sql server 2008 using c#
Apr 2 2014 2:12 AM
pls help me how to insert time.
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString);
conn.Open();
TextBox5.Text = System.DateTime.Now.ToShortDateString();
TextBox5.Enabled = false;
TextBox6.Text = System.DateTime.Now.ToLongTimeString();
TextBox6.Enabled = false;
conn.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString);
conn.Open();
string insert = "insert into customer (C_id,C_Name,Emp_id,C_pro,date,Time,Phone_No,Problem_Status) values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "',)";
SqlCommand cmd = new SqlCommand(insert, conn);
cmd.ExecuteNonQuery();
Response.Write("<script>alert('successfully Recorded');</script>");
conn.Close();
}
catch(Exception ex)
{
Response.Write("Error:" + ex.ToString());
}
it shows
Error
Error:System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near ')'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Emp_customer.Button1_Click(Object sender, EventArgs e) in c:\Users\pr@v!nk@rth!k\Documents\Visual Studio 2010\WebSites\CallCenterMgt\Emp\customer.aspx.cs:line 36 ClientConnectionId:26d3c409-6742-4b7e-9a7c-fd5d0a5e24be
Reply
Answers (
1
)
how we can get date in between in asp.net
one session at a time for one user