首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

求告诉,该怎么解决

2012-06-12 
求告诉Dim id As IntegerDim rows As IntegerDim s As Stringrows DataGridView1.CurrentCellAddress.Y.

求告诉
Dim id As Integer
  Dim rows As Integer
  Dim s As String
  rows = DataGridView1.CurrentCellAddress.Y.ToString()
  id = CInt(DataGridView1.Rows(rows).Cells(0).Value)
  Label2.Text = id
  If ComboBox1.SelectedIndex = -1 Then
  MsgBox("选择商品类型", MsgBoxStyle.OkOnly, "信息提示")
  s = ""
  Else
  s = ComboBox1.Text
  End If
  If s = "食品类" Then

  Dim mystr As String
  Dim mysql As String
  Dim myconn As New OleDbConnection
  Dim myds As New DataSet
  mystr = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\食品类.mdb;")
  myconn.ConnectionString = mystr
  myconn.Open()
  mysql = "select * from 食品类"
  Dim myda As New OleDbDataAdapter(mysql, myconn)
  myda.Fill(myds, "食品类")
  Dim mycmd As New OleDbCommand
  mysql = "update 食品类 set " & "是否缺货='" & ComboBox2.Text & "' where 编号= '" & id & "'"
  mycmd.Connection = myconn
  mycmd.CommandText = mysql
  mycmd.ExecuteNonQuery()
  myconn.Close()
  myds.Clear()
  myda.Fill(myds, "食品类")
end if 


标准类型不匹配什么原因



[解决办法]
你的【编号】字段是什么类型的,数字型的话不用加【'】。还有你的字段名如果是中文的话,最好加上【[]】。
[解决办法]
Dim rows As Integer
rows = DataGridView1.CurrentCellAddress.Y.ToString()
定义的是整形,赋值的是字符串
[解决办法]
mystr = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\食品类.mdb;")

[解决办法]
mysql = "update 食品类 set " & "是否缺货='" & ComboBox2.Text & "' where 编号= '" & id & "'"
是否缺货是什么类型?

热点排行