Windows 7不能正确运行xb的vb应用程序 [英] windows 7 can't run vb app properly as xp

查看:90
本文介绍了Windows 7不能正确运行xb的vb应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个vb.net应用程序,该应用程序可以在WindowsXP中很好地运行.

我只是试图将其安装到Windows7中,然后在保存方法中发生了错误.
除此之外,其他方法也可以.

是什么原因造成的?代码还是Windows?
如果有人知道就告诉我.

该方法的代码如下(我的编码可能不干净^^)

I had created a vb.net application which is able to run well in windowsXP.

I''d just tried to install it into windows7 and an error occured in a saving method.
Other method is ok except for this.

What should be the cause of it? codes or windows?
If anyone knows just tell me.

The code of this method is below (My coding may not clean ^^)

Dim de As OleDbDataReader
        Dim cn As OleDbConnection = New OleDbConnection(MySTR)
        Dim cmd As OleDbCommand
        Dim cmdStr As String = ""
        Dim dt As DataTable = New DataTable
        Dim working_info_id As Integer
        Dim state As String = ""
        Dim row As Integer = 0
        Dim mbresult As MsgBoxResult
        Dim emp_id As Integer = 0
        'Dim dt As Date = dtworkingInfo.Value.Date.Day & "/" & dtworkingInfo.Value.Date.Month & "/" & dtworkingInfo.Value.Date.Year-543
        mbresult = MsgBox("กรณีที่คุณต้องการบันทึกข้อมูลนี้ กรุณากดปุ่ม 'OK'" & vbCrLf & _
                      "ถ้าไม่ต้องการ กรุณากดปุ่ม'Cancel'", vbOKCancel, "!แจ้งเตือน")
        'Try


        progressbarUpdate.Maximum = gvemployee.Rows.Count * 10

        Select Case mbresult
            Case vbOK
                Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
                progressbarUpdate.Visible = True

                progressbarUpdate.Value = 10
                For i As Integer = 0 To gvemployee.Rows.Count - 2
                    If i <= (gvemployee.Rows.Count * 10) Then
                        progressbarUpdate.Value = (i * 10)
                    End If

                    If gvemployee.Rows(i).Cells(4).Value = True Then
                        state = "ทำงาน"
                        row = 4
                    ElseIf gvemployee.Rows(i).Cells(5).Value = True Then
                        state = "ลาป่วยครึ่งวัน"
                        row = 5
                    ElseIf gvemployee.Rows(i).Cells(6).Value = True Then
                        state = "ลาป่วยเต็มวัน"
                        row = 6
                    ElseIf gvemployee.Rows(i).Cells(7).Value = True Then
                        state = "ลากิจครึ่งวัน"
                        row = 7
                    ElseIf gvemployee.Rows(i).Cells(8).Value = True Then
                        state = "ลากิจเต็มวัน"
                        row = 8
                    ElseIf gvemployee.Rows(i).Cells(9).Value = True Then
                        state = "ขาด"
                        row = 9
                    Else
                        cmd = New OleDbCommand("select working_state from tb_working_info where emp_id=" & gvemployee.Rows(i).DataBoundItem("emp_id").ToString & " and working_date=#" & dtworkingInfo.Value.Date.Month & "/" & dtworkingInfo.Value.Date.Day & "/" & dtworkingInfo.Value.Date.Year & "#", cn)
                        de = cmd.ExecuteReader
                        If de.Read Then
                            state = de("working_state")
                        Else
                            state = "-"
                        End If

                    End If
                    emp_id = gvemployee.Rows(i).DataBoundItem("emp_id")
                    de = getState(emp_id)

                    Threading.Thread.Sleep(10)
                    'Try
                    If de.Read Then
                        id = de("emp_id")
                        working_info_id = de("id")
                        cmdStr = "update tb_working_info set emp_id=" & emp_id & ",working_date=#" & dtworkingInfo.Value.Date.Month & "/" & dtworkingInfo.Value.Date.Day & "/" & dtworkingInfo.Value.Date.Year & "#,working_state='" & state & "' where id=" & working_info_id
                    Else
                        cmdStr = "insert into  tb_working_info (emp_id,working_date,working_state)  values (" & emp_id & ",#" & dtworkingInfo.Value.Date.Month & "/" & dtworkingInfo.Value.Date.Day & "/" & dtworkingInfo.Value.Date.Year & "#,'" & state & "')"
                    End If
                    With cn
                        If .State = ConnectionState.Open Then .Close()
                        .ConnectionString = MySTR
                        .Open()
                    End With
                    cmd = New OleDbCommand(cmdStr, cn)
                    If state <> "" Then
                        cmd.ExecuteNonQuery()
                    End If
                    state = ""
                                        Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
                    Threading.Thread.Sleep(10)
                Next
                cancelselectedCell = 0


                progressbarUpdate.Value = gvemployee.Rows.Count * 10

                cancelselectedCell = 0
                progressbarUpdate.Visible = False
                Dim dr1 = retrieveEmpInfo()
                Dim da As DataTable = New DataTable
                da.Load(dr1)
                gvemployee.DataSource = da
                Me.Cursor = System.Windows.Forms.Cursors.Default
            Case vbCancel
                cancelselectedCell = 0
                Dim dr1 = retrieveEmpInfo()
                Dim da As DataTable = New DataTable
                da.Load(dr1)
                gvemployee.DataSource = da
                (Me.PayrollDataSet.tb_employee, "#" & dtworkingInfo.Value.Date & "#", "#" & dtworkingInfo.Value.Date & "#", "#" & dtworkingInfo.Value.Date & "#")
        End Select
        Dim countemp As OleDbDataReader = countEmployee()
        If countemp.Read Then
            count = countemp("countEmp")
        End If
        Dim dr As OleDbDataReader = checkWorkingInfo() 'ตรวจสอบว่าเคยลงข้อมูลวันที่นี้หรือยัง
        If Not dr.Read Then
            cbcheckAll.Enabled = True
        Else
            cbcheckAll.Enabled = False
        End If
        progressbarUpdate.Visible = False



道歉,不方便..
这是错误消息 http://image.free.in.th/z/im/jdddd.jpg [ ^ ]
感谢大家的帮助.



Apology for an unconvinient..
this is the error message http://image.free.in.th/z/im/jdddd.jpg[^]
thanks for helping everyone.

推荐答案

最有可能是
与权限相关的问题.
在win 7中Access数据库变为写入
保护.并且它限制用户在
中添加或修改 数据库.
您应该授予用户所有权限.
如果我的假设是正确的,请访问链接[ ^ ]
请按照以下步骤操作,然后尝试保存
Most Probably It must be the
Permission related issue.
In win 7 Access database becomes write
proteced .And it restricts user to add or modify into
the database.
You should give the user all Permissions.
If my Assumtions are true.Visit the link [^]
Follow the Steps and then try to Save


基于错误,权限不是问题.您的问题似乎是您正在尝试使用未返回主键或试图在错误位置使用查询的查询.例如,代码正在尝试执行Update命令,并且您为其SQL提供了SELECT查询.
Based on the error, permissions are not the problem. Your problem seems to be that you are trying to use a query that either didn''t return a primary key or are trying to use a query in the wrong place. For example, the code is trying to execute an Update command and you supplied a SELECT query for it''s SQL.


这篇关于Windows 7不能正确运行xb的vb应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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