多步OLE DB操作生成错误。检查每个OLE DB状态值(如果可用)。没有工作。? [英] Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.?

查看:73
本文介绍了多步OLE DB操作生成错误。检查每个OLE DB状态值(如果可用)。没有工作。?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我已经花了太多时间进入应该是一个简单的编码,我无法弄清楚为什么这不起作用。我正在尝试为我的程序创建一个保存文件,并且在大多数情况下它可以工作,但我无法保存到txt的一件事是多列列表视图。相反,我在数据库中创建了一个被擦除的表,然后在用户保存时用新数据重写。但是,出于某种原因,我收到标题中的错误。



我的连接字符串:



Okay I have put way too much time into what should have been a simple bit of coding, I can not figure out why this doesn't work. I am trying to create a save file for my program and for the most part it works but the one thing I can't save into a txt is the multi-column listview. Instead, i created a table in the database that gets wiped, and then rewritten with the new data when the user saves. However, for some reason, I am getting the error that's in the title.

My connection string:

Public strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
System.Environment.CurrentDirectory & "\OmegaTestDatabase.mdb"





保存代码:





Save Code:

Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click

        Dim DbConnection As New OleDbConnection(strConnectionString)
        Dim SqlQry As New OleDbCommand("INSERT INTO Inventory VALUES (@ItemName, @ItemQuality, @SellPrice)", DbConnection)
        Dim DeleteCmd As New OleDbCommand("DELETE FROM Inventory WHERE [Sell Price] >= 0", DbConnection)

        DbConnection.Open()

        DeleteCmd.CommandType = CommandType.Text

        DeleteCmd.Connection = DbConnection

        DeleteCmd.ExecuteNonQuery()

        DeleteCmd.Dispose()

        DbConnection.Close()

        DbConnection.Open()

        For Each item As ListViewItem In ItemBagList.Items
            SqlQry.Parameters.AddWithValue("@ItemName", item.SubItems(0))
            SqlQry.Parameters.AddWithValue("@ItemQuality", item.SubItems(1))
            SqlQry.Parameters.AddWithValue("@SellPrice", item.SubItems(2))

            SqlQry.ExecuteNonQuery()

        Next

        DbConnection.Close()

        Dim sfd As New SaveFileDialog
        sfd.Filter = "Text Files *.txt|*.txt"
        sfd.Title = "Save File"
        sfd.ShowDialog()
        Dim myPath As String = sfd.FileName

        ' To save
        FileOpen(1, myPath, OpenMode.Output)
        PrintLine(1, PlaySTR.Value)
        PrintLine(1, PlayLUC.Value)
        PrintLine(1, PlayAGI.Value)
        PrintLine(1, PlayINT.Value)
        PrintLine(1, PlaySpirit.Value)
        PrintLine(1, PlayLife.Value)
        PrintLine(1, PlayHP.Value)
        PrintLine(1, PlaySP.Value)
        PrintLine(1, PlayMDEF.Value)
        PrintLine(1, PlayPDEF.Value)
        PrintLine(1, PlayRDEF.Value)
        PrintLine(1, PlayMATK.Value)
        PrintLine(1, PlayPATK.Value)
        PrintLine(1, PlayRATK.Value)
        PrintLine(1, WpnMinDmg.Value)
        PrintLine(1, WpnMaxDmg.Value)
        PrintLine(1, PlaySkillDmg.Value)
        PrintLine(1, PlayMAcc.Value)
        PrintLine(1, PlayPAcc.Value)
        PrintLine(1, PlayRAcc.Value)
        PrintLine(1, PlayCritChance.Value)
        PrintLine(1, PlayCritMult.Value)
        PrintLine(1, BlockValue.Value)
        PrintLine(1, PlayDodge.Value)
        PrintLine(1, PetSTR.Value)
        PrintLine(1, PetLUC.Value)
        PrintLine(1, PetAGI.Value)
        PrintLine(1, PetINT.Value)
        PrintLine(1, PetSpirit.Value)
        PrintLine(1, PetLife.Value)
        PrintLine(1, PetHP.Value)
        PrintLine(1, PetSP.Value)
        PrintLine(1, PetMDEF.Value)
        PrintLine(1, PetPDEF.Value)
        PrintLine(1, PetRDEF.Value)
        PrintLine(1, PetMATK.Value)
        PrintLine(1, PetPATK.Value)
        PrintLine(1, PetRATK.Value)
        PrintLine(1, PetMAcc.Value)
        PrintLine(1, PetPAcc.Value)
        PrintLine(1, PetRAcc.Value)
        PrintLine(1, PetCritChance.Value)
        PrintLine(1, PetCritMult.Value)
        PrintLine(1, PetDodge.Value)
        PrintLine(1, PetSkillDmg.Value)
        PrintLine(1, MobHP.Value)
        PrintLine(1, MobSP.Value)
        PrintLine(1, MobMDEF.Value)
        PrintLine(1, MobPDEF.Value)
        PrintLine(1, MobRDEF.Value)
        PrintLine(1, MobMATK.Value)
        PrintLine(1, MobPATK.Value)
        PrintLine(1, MobRATK.Value)
        PrintLine(1, MobMAcc.Value)
        PrintLine(1, MobPAcc.Value)
        PrintLine(1, MobRAcc.Value)
        PrintLine(1, MobCritChance.Value)
        PrintLine(1, MobCritMult.Value)
        PrintLine(1, MobDodge.Value)
        PrintLine(1, RaceCbo.SelectedItem)
        PrintLine(1, PlaySkillCheck.Checked)
        PrintLine(1, PetSkillCheck.Checked)
        PrintLine(1, MobSkillCheck.Checked)
        PrintLine(1, PetType.SelectedItem)
        PrintLine(1, PlaySkillLvl.Value)
        PrintLine(1, PetSkillLvl.Value)
        PrintLine(1, PetLevelNum.Value)
        PrintLine(1, MobCbo.SelectedItem)
        PrintLine(1, GoldValue.Value)
        PrintLine(1, SilverValue.Value)
        PrintLine(1, CopperValue.Value)
        PrintLine(1, SkillBar1.SelectedItem)
        PrintLine(1, SkillBar2.SelectedItem)
        PrintLine(1, SkillBar3.SelectedItem)
        PrintLine(1, SkillBar4.SelectedItem)
        PrintLine(1, SkillBar5.SelectedItem)
        PrintLine(1, SkillBar6.SelectedItem)
        PrintLine(1, SkillBar7.SelectedItem)
        PrintLine(1, SkillBar8.SelectedItem)
        PrintLine(1, SkillBar9.SelectedItem)
        PrintLine(1, SkillBar10.SelectedItem)
        PrintLine(1, SkillLvl1.Value)
        PrintLine(1, SkillLvl2.Value)
        PrintLine(1, SkillLvl3.Value)
        PrintLine(1, SkillLvl4.Value)
        PrintLine(1, SkillLvl5.Value)
        PrintLine(1, SkillLvl6.Value)
        PrintLine(1, SkillLvl7.Value)
        PrintLine(1, SkillLvl8.Value)
        PrintLine(1, SkillLvl9.Value)
        PrintLine(1, SkillLvl10.Value)
        'saves the values of each of the above controls into a txt file with one line per value
        FileClose(1)

    End Sub





我完全亏损,有人请帮助我吗?



编辑:表格和列表视图都有3列,标题为项目名称,项目质量和销售价格。我试图将数据库中的卖价列从数字更改为短文本,然后返回到数字并且没有帮助,所以问题不在于数据类型。



问题发生在For Each的第一次迭代中... Next



I'm at a complete loss, someone please help me?

The table and the listview both have 3 columns titled Item Name, Item Quality, and Sell Price. I have attempted to change the Sell Price column in the database from number, to Short Text, and back to Number and that didn't help, so the problem isn't with datatype.

The problem occurs during the first iteration of For Each... Next

推荐答案

将循环更改为:



Change loop to:

For Each item As ListViewItem In ItemBagList.Items
           SqlQry.Parameters.AddWithValue("@ItemName", item.SubItems(0).Text)
           SqlQry.Parameters.AddWithValue("@ItemQuality", item.SubItems(1).Text)
           SqlQry.Parameters.AddWithValue("@SellPrice", item.SubItems(2).Text)

           SqlQry.ExecuteNonQuery()
       Next


这篇关于多步OLE DB操作生成错误。检查每个OLE DB状态值(如果可用)。没有工作。?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆