VB.NET为什么写汉字进数据库的时候出现乱码
就是用VB.NET写的数据库后台。插入记录的时候。汉字全部变成为乱码了。怎么解决。谢谢各位高手...
就是用VB.NET写的数据库后台。插入记录的时候。汉字全部变成为乱码了。怎么解决。谢谢各位高手
展开
展开全部
Public Function addEquipment() As Integer
Dim flag As Integer = 0
Dim strsql As String = ""
emditInfor = New DBHelper()'DBHelper()为数据库操作文件,包括数据库的连接插入更新查找等等
Try
strsql = "INSERT INTO Equipment ("
strsql &= "AssetsID,"
...
strsql &= "Size)"
strsql &= "VALUES ("
strsql &= "@AssetsID,"
...
strsql &= "@Size)"
Dim cmd As SqlCommand = emditInfor.GetSqlStringCommond(strsql)
emditInfor.AddInParameter(cmd,"@AssetsID",SqlDbType.NVarChar, "1314")
...
emditInfor.AddInParameter(cmd, "@Size", SqlDbType.NVarChar, "5")
flag = emditInfor.ExecuteNonQuery(cmd)'返回受影响的行数
Catch ex As Exception
End Try
Return flag
End Function
像这样以参数的形式传值进去就可以了。
Dim flag As Integer = 0
Dim strsql As String = ""
emditInfor = New DBHelper()'DBHelper()为数据库操作文件,包括数据库的连接插入更新查找等等
Try
strsql = "INSERT INTO Equipment ("
strsql &= "AssetsID,"
...
strsql &= "Size)"
strsql &= "VALUES ("
strsql &= "@AssetsID,"
...
strsql &= "@Size)"
Dim cmd As SqlCommand = emditInfor.GetSqlStringCommond(strsql)
emditInfor.AddInParameter(cmd,"@AssetsID",SqlDbType.NVarChar, "1314")
...
emditInfor.AddInParameter(cmd, "@Size", SqlDbType.NVarChar, "5")
flag = emditInfor.ExecuteNonQuery(cmd)'返回受影响的行数
Catch ex As Exception
End Try
Return flag
End Function
像这样以参数的形式传值进去就可以了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询