我是先运行下面的代码
Private Sub txtColorID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles combColorID.SelectedIndexChanged
If Me.txtShoesID.Text.Trim.Length = 0 And Me.txtShoesID.Text.Trim.Length Then
MsgBox("请输入正确的数据!", MsgBoxStyle.Information, "提示")
Me.txtShoesID.Focus()
Me.CombNoID.Focus()
Exit Sub
End If
sqlCmd.CommandText = "select 名称 ,尺寸 ,颜色,价格,数量 from 库存表 where 名称=@ShoesID and 尺寸=@NoID and 颜色=@ColorID"
sqlCmd.Parameters.Add("@shoesID", SqlDbType.VarChar)
sqlCmd.Parameters("@shoesID").Value = Me.txtShoesID.Text
sqlCmd.Parameters.Add("@noID", SqlDbType.Int)
sqlCmd.Parameters("@noID").Value = Me.CombNoID.Text
sqlCmd.Parameters.Add("@colorID", SqlDbType.VarChar)
sqlCmd.Parameters("@colorID").Value = Me.combColorID.SelectedItem
sqlCmd.Connection = Module1.sqlconn
sqlDa.SelectCommand = sqlCmd
Dim sqlDr As SqlDataReader
Try
Module1.sqlconn.Open()
sqlDr = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection)
If sqlDr.Read Then
Me.txtUnitPrice.Text = sqlDr("价格")
Me.txtStockQuantity.Text = sqlDr("数量")
End If
Catch ex As Exception
MsgBox("发生错误:" & ex.Message)
End Try
End Sub
然后在运行下面的代码```
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String
If Module1.sqlconn.State <> ConnectionState.Open Then
Module1.sqlconn.Open()
End If
str = "insert into 销售表(名称,尺寸,颜色,价格) values ('" & txtShoesID.Text.Trim() & "','" & CombNoID.SelectedItem.ToString() & "','" & combColorID.SelectedItem.ToString() & "','" & txtUnitPrice.Text.Trim() & "')"
sqlCmd.Connection = Module1.sqlconn
sqlCmd.CommandType = CommandType.Text
sqlCmd.CommandText = str
sqlDa.SelectCommand = sqlCmd
MessageBox.Show("销售成功", "提示信息")
txtShoesID.Text = ""
CombNoID.Text = ""
combColorID.Text = ""
txtShoesID.Focus()
就会跳出先面的图片的问题,小弟想了很多天就是解决不来``也不知道怎么改,求那位大哥能帮小弟一把。。