PDA

View Full Version : نحوه چك كردن null بودن يك object در هنگام اصلاح ركورد



swallow.pa
جمعه 23 تیر 1391, 20:28 عصر
سلام به همه دوستان

من با اصلاح يك كد مشكل دارم يك فيلدي دارم با نام comment كه قابليت null دارد خب حالا طبق اين كد زيري كه براي اصلاح گذاشتم چطور قابليت null اونو چك كنم

txtcomment رو قرمز كردم مي خوام اين ابجكت رو كنترل كنم كه نول هست يا نيست و اگه نول هست چطوري كد بنويسم
ممنون





Sub Edit_InstructionHeader()
Using Cmd As New SqlClient.SqlCommand(Nothing, Cn)
Cmd.CommandText = String.Format(" UPDATE dbo.ProductActionHeader SET ProductActionHeaderDate='{0}',Comment='{1}' WHERE ProductActionHeaderId= {2} " _
txtProductActionHeaderDate.Text, txtComment.Text, txtProductActionHeaderNum.Text)
If Cn.State = ConnectionState.Closed Then Cn.Open()
Cmd.ExecuteNonQuery()
Cn.Close()
End Using
End Sub