0
我试图在我的SQL Server数据库中插入字符串到char(20)
列。如何将字符串转换为Char(20)sql数据类型
我设定的字符串为等于一个值,然后将其添加到每次我尝试它结束了在数据库
thisstring = "1914"
cmd.Parameters.AddWithValue("@code", thisstring)
然而
我需要它看起来像1913, 000000, 000001
的。
当我尝试垫用空格
thisstring= thisstring.PadLeft(20, " ")
或
thisstring = " " & thisstring
我越来越
字符串或二进制数据字符串将被截断
即使该字段不是总共20个字符
我在做什么错了?
编辑***这里是SQL Server
什么是SQL或'cmd',即'cmd.CommandText'存储过程调用标准语法试试? – shahkalpesh
thisstring = thisstring.PadLeft(20,“”)应该已经工作了。你可以仔细检查参数定义。这可能与表格定义不同。 –
cmd =新的SqlCommand(strSQL,conn)和执行是cmd.ExecuteNonQuery() – user867621