未解决的问题,,
代码错的哪里??
CONN2已经定义
Dim conn2 As New SqlConnection("server=localhost;packet size=4096;integrated security=SSPI;data source=localhost;pe" & _
"rsist security info=False;initial catalog=商场管理系统")
Try
If Trim(txtgoodsnumber.text) <> Nothing Then
If TxtYear.TextLength = 4 And Val(TxtDay.Text) < 32 And Val(TxtDay.Text) > 0 Then
Dim datestr As String
datestr = TxtYear.Text & "-" & CmbMonth.Text & "-" & TxtDay.Text
Dim cmd As New SqlCommand
cmd.CommandText = "insert into 进货表(商品号,品名,规格,单位,产地,类型,进价,批发价,零售价,进货日期,供应商,供应商信息)values('" & _
Trim(TxtGoodsNumber.Text) & " ','" & TxtGoodsName.Text & "','" & Trim(TxtSpec.Text) & _
" ','" & Trim(TxtUnit.Text) & "','" & Trim(TxtProducing.Text) & "','" & CmbType1.Text & "','" & Trim(TxtPrice.Text) & _
" ','" & Trim(TxtTradPrice.Text) & "','" & Trim(TxtRetailPrice.Text) & "','" & datestr & "','" & Trim(TxtAmount.Text) & _
"','" & Trim(TxtProvider.Text) & "','" & Trim(TxtProviderIfo.Text) & "')"
conn2.Open()
cmd.Connection = conn2
// 'comstr = "insert into 进货表 values('" & Trim(TxtGoodsNumber.Text) & " ','" & TxtGoodsName.Text & "','" & Trim(TxtSpec.Text) & _
// '" ','" & Trim(TxtUnit.Text) & "','" & Trim(TxtProducing.Text) & "','" & CmbType1.Text & "','" & Trim(TxtPrice.Text) & _
// '" ','" & Trim(TxtTradPrice.Text) & "','" & Trim(TxtRetailPrice.Text) & "','" & datestr & "','" & Trim(TxtAmount.Text) & _
// '"','" & Trim(TxtProvider.Text) & "','" & Trim(TxtProviderIfo.Text) & "')"
/ / 'Dim cmd As New SqlCommand(comstr, SqlConnection1)
/ / 'SqlConnection1.Open()
cmd.ExecuteNonQuery()
conn2.Close()
MsgBox("添加成功 !!")
Else
MsgBox("输入日期不正确")
// 'Exit Sub
End If
Else
MsgBox("商品号不能为空")
TxtGoodsNumber.Focus()
//'Exit Sub
End If
Catch //'ex As Exception
MsgBox("已有同种物品存在!!", MsgBoxStyle.Information, "提示")
End Try
代码错的哪里?谢谢
以下这句有错: { cmd.ExecuteNonQuery()}
错误信息:
未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。
其他信息: 系统错误。
也有引入命名空间啊
另:进货日期,供应商,中间要多一个列(进货数量)
谢谢啊
问题点数:50、回复次数:6Top
1 楼ljhkim6()回复于 2006-03-03 20:54:01 得分 0
("server=localhost;packet size=4096;integrated security=SSPI;data source=localhost;pe" & _
"rsist security info=False;initial catalog=商场管理系统")
"server=; user id=sa;password=yourpassword;database=商场管理系统"Top
2 楼weiyan19820315(魏岩)回复于 2006-03-03 22:28:42 得分 0
'" & Trim(TxtPrice.Text) & _
" ','" & Trim(TxtTradPrice.Text) & "','" & Trim(TxtRetailPrice.Text) & "'
要是你的字段"进价,批发价,零售价"不是字符型的,上面这句就不对了,改成:
" & Trim(TxtPrice.Text) & _
" ," & Trim(TxtTradPrice.Text) & "," & Trim(TxtRetailPrice.Text) & "
Top
3 楼zhouxiaotan(夜雨悠扬)回复于 2006-03-03 23:14:26 得分 0
其实提示信息已经很清楚了,
你检查你的数据库定义中是数值型和日期的字段,看看是否相符
另外,把这个SQL语句放到查询分析器中运行一下,看看是什么地方错了Top
4 楼blaite(黑加白(感叹了))回复于 2006-03-04 00:31:20 得分 0
忘了帶暫住證,家都回不了了...回來吐吐口水
c-a-w 他老母!!!!!
誰說種族歧視在中國不存在?
我們外地人就是低等人,
人家懂得享受,四處搞綠化,
其費用卻從我們所得稅收中搾取,
現在還多出個綠化費,
我們要掏腰包,給人家
走到哪裡還得掛著個類似狗牌一樣的東西,形影不離
Top
5 楼zz0596(无~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)回复于 2006-03-05 20:35:02 得分 0
thanks
Top
6 楼drk928(一起看斜阳)回复于 2006-03-07 11:02:27 得分 0
低级错误...Top




