0
我更新我的代碼加入。價值= DBNull.Value中的臺詞更新數據庫
任何建議,關於接受日期和時間文本框的任何建議空值更新數據庫/建議高度讚賞的一切,如果你還沒有設置日期時間字段的允許空屬性,將其設置爲允許空,使之接受空
Dim cmd As SqlCommand = sqlconn.CreateCommand
sqlconn.Open()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "UpdateEquipmentProfile"
'declare the variables'
cmd.Parameters.Add("@OE_ID", SqlDbType.VarChar, 11, "oeq-su-999").Value = DBNull.Value
cmd.Parameters.Add("@OE_Category", SqlDbType.Char, 3, "COM").Value = DBNull.Value
cmd.Parameters.Add("@OE_SubCategory", SqlDbType.Char, 3, "SU").Value = DBNull.Value
cmd.Parameters.Add("@OE_Name", SqlDbType.VarChar, 35, "adminpmis01").Value = DBNull.Value
cmd.Parameters.Add("@OE_User", SqlDbType.VarChar, 35, "Ivan").Value = DBNull.Value
cmd.Parameters.Add("@OE_Brand", SqlDbType.VarChar, 15, "DELL").Value = DBNull.Value
cmd.Parameters.Add("@OE_Model", SqlDbType.VarChar, 35, "optiplex").Value = DBNull.Value
cmd.Parameters.Add("@OE_Specs", SqlDbType.VarChar, 1000, "dualcore").Value = DBNull.Value
cmd.Parameters.Add("@OE_SerialNo", SqlDbType.VarChar, 35, "sgh5960").Value = DBNull.Value
cmd.Parameters.Add("@OE_PropertyNo", SqlDbType.VarChar, 35, "j7h7h6g6f2").Value = DBNull.Value
cmd.Parameters.Add("@OE_MacAddress", SqlDbType.VarChar, 100, "j7h7:h6g6f2").Value = DBNull.Value
cmd.Parameters.Add("@OE_Static_IP", SqlDbType.VarChar, 15, "192.168.1.5").Value = DBNull.Value
cmd.Parameters.Add("@OE_Vendor", SqlDbType.VarChar, 35, "ADWAYS").Value = DBNull.Value
cmd.Parameters.Add("@OE_PurchaseDate", SqlDbType.SmallDateTime).Value = DBNull.Value
cmd.Parameters.Add("@OE_WarrantyInclusiveYear", SqlDbType.Int).Value = DBNull.Value
cmd.Parameters.Add("@OE_WarrantyStatus", SqlDbType.Char, 2, "IN").Value = DBNull.Value
cmd.Parameters.Add("@OE_Status", SqlDbType.VarChar, 15, "Good").Value = DBNull.Value
cmd.Parameters.Add("@OE_Dept_Code", SqlDbType.Char, 3, "ADM").Value = DBNull.Value
cmd.Parameters.Add("@OE_Location_Code", SqlDbType.Char, 8, "ADM_OFC").Value = DBNull.Value
cmd.Parameters.Add("@OE_Remarks", SqlDbType.VarChar, 1000, "ACTIVE").Value = DBNull.Value
cmd.Parameters("@OE_ID").Value = txtOEID.Text
cmd.Parameters("@OE_Category").Value = cmbCategory.Text
cmd.Parameters("@OE_SubCategory").Value = cmbSubCategory.Text
cmd.Parameters("@OE_Name").Value = txtName.Text
cmd.Parameters("@OE_User").Value = txtUser.Text
cmd.Parameters("@OE_Brand").Value = cmbBrand.Text
cmd.Parameters("@OE_Model").Value = cmbModel.Text
cmd.Parameters("@OE_Specs").Value = txtSpecs.Text
cmd.Parameters("@OE_SerialNo").Value = txtSerialNo.Text
cmd.Parameters("@OE_PropertyNo").Value = txtPropertyNo.Text
cmd.Parameters("@OE_MacAddress").Value = txtMacAddress.Text
cmd.Parameters("@OE_Static_IP").Value = txtStaticIp.Text
cmd.Parameters("@OE_Vendor").Value = txtVendor.Text
cmd.Parameters("@OE_PurchaseDate").Value = txtPurchaseDate.Text
cmd.Parameters("@OE_WarrantyInclusiveYear").Value = txtWarrantyInclusiveYear.Text
cmd.Parameters("@OE_WarrantyStatus").Value = txtWarrantyStatus.Text
cmd.Parameters("@OE_Status").Value = txtStatus.Text
cmd.Parameters("@OE_Dept_Code").Value = cmbDeptCode.Text
cmd.Parameters("@OE_Location_Code").Value = cmbLocationCode.Text
cmd.Parameters("@OE_Remarks").Value = txtRemarks.Text
cmd.ExecuteNonQuery()
MsgBox("Successfully Updated Equipment Profile")
sqlconn.Close()
set @ OE_PurchaseDate = NULL到SP中。並不傳遞參數,所以默認情況下它採用NULL值 – 2013-04-30 03:25:21
@SaroopTrivedi將這我需要發生'@OE_PurchaseDate varchar(35)'更改爲'@ OE_PurchaseDate = NULL'在我的存儲過程? – ivandinglasan 2013-04-30 03:43:08
@OE_PurchaseDate smalldatetime = NULL – 2013-04-30 04:22:32