Sam wrote:
> Hi,
> I have problem inserting null value through SQLCommand in VB.NET to SQL
> Server.
>
> dim cm as new sqlcommand
> cm.commandtext = "insert into table1 (field1, field2, ....) values(var1,
> var2,....)"
>
> How to assign var2 <== NULL Value, so in SQL Server will appear as null
> value ?
Simply do not specify the field:
cm.commandtext = "insert into table1 (field1, field3, ....) values(var1,
var3,....)"
Or, as Jon said, use parameters and set the value to DBNull.Value or to
Nothing (VB.NET) or null (C#)
FB
--
Get LLBLGen Pro, the new O/R mapper for .NET:
http://www.llblgen.com
My .NET Blog:
http://weblogs.asp.net/fbouma
Microsoft C# MVP