|
|
|
ผมจะเก็บวันที่ลงดาต้าเบสแล้วมันขึ้นว่า Conversion failed when converting date and/or time from character string. |
|
|
|
|
|
|
|
Code (C#)
protected void bt_Save_Click(object sender, EventArgs e)
{
string user = txt_UserName.Text ,pass=txt_PassWord.Text, name = txt_Name.Text , lastname=txt_SurName.Text, phone= txt_Phone.Text,mail=txt_EMail.Text, brith=""+ddb_BirthDay.Text+""+ddb_BirthMonth.Text+""+ddb_BirthYear.Text ;
string HomeNum = txt_HomeNum.Text, Tambol = txt_tambol.Text, Amphor = txt_Auphor.Text, Province = txt_Province.Text, PostCode = txt_ZipCode.Text;
string strConn = WebConfigurationManager.ConnectionStrings["ezyPetShopConnectionString"].ConnectionString;
SqlConnection Conn = new SqlConnection(strConn);
Conn.Open();
string sqlregist1 = "INSERT INTO Customer(Username,Password,CustomerName,CustomerLastName,CustomerPhone,CustomerEMail,CustomerBrith) VALUES (@user,@pass,@name,@lastname,@phone,@mail,@brith) ";
string sqlregist2 = "INSERT INTO Customer_Address(Username,HomeNum,Tambol,Amphor,Province,PostCode) VALUES (@user,@HomeNum,@Tambol,@Amphor,@Province,@PostCode) ";
SqlCommand com = new SqlCommand(sqlregist1,Conn);
com.Parameters.AddWithValue("@user",user);
com.Parameters.AddWithValue("@pass", pass);
com.Parameters.AddWithValue("@name", name);
com.Parameters.AddWithValue("@lastname", lastname);
com.Parameters.AddWithValue("@phone", phone);
com.Parameters.AddWithValue("@mail", mail);
com.Parameters.AddWithValue("@brith", brith);
SqlCommand com2 = new SqlCommand(sqlregist2, Conn);
com2.Parameters.AddWithValue("@user",user);
com2.Parameters.AddWithValue("@HomeNum", HomeNum);
com2.Parameters.AddWithValue("@Tambol", Tambol);
com2.Parameters.AddWithValue("@Amphor", Amphor);
com2.Parameters.AddWithValue("@Province", Province);
com2.Parameters.AddWithValue("@PostCode", PostCode);
com.ExecuteNonQuery();
com2.ExecuteNonQuery();
}
Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), C#, VS 2010 (.NET 4.x)
|
|
|
|
|
|
Date :
2012-02-08 01:28:03 |
By :
nnn |
View :
1251 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
brith=01มกราคม2012 ครับ
|
|
|
|
|
Date :
2012-02-08 12:06:35 |
By :
nnn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แบบนั้นมันถูก Format แล้วเหรอครับ
|
|
|
|
|
Date :
2012-02-08 12:49:36 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ
|
|
|
|
|
Date :
2012-02-08 13:12:30 |
By :
nnn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|