Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 612|回复: 5
打印 上一主题 下一主题

VB.NET 求助啊!

[复制链接]

39

主题

1

好友

3143

积分

本站名嘴

Rank: 11Rank: 11

跳转到指定楼层
1#
发表于 2013-7-18 11:34 AM |只看该作者 |倒序浏览
本帖最后由 ~美妹一號~ 于 2013-7-18 11:37 AM 编辑








我的error是Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
read database 然后拿资料出来做print receipt~可是。。一直出现这个问题。求助啊!!




收藏收藏0

0

主题

0

好友

106

积分

高级会员

Rank: 3Rank: 3Rank: 3

2#
发表于 2013-7-18 12:07 PM |只看该作者
可以把你中error的code放出来看看吗?


回复

使用道具 举报

39

主题

1

好友

3143

积分

本站名嘴

Rank: 11Rank: 11

3#
发表于 2013-7-18 07:49 PM |只看该作者
tomiverson 发表于 2013-7-18 12:07 PM
可以把你中error的code放出来看看吗?

Imports System.IO
Imports System.Data.OleDb
Public Class frmPrintCash

    Dim ListDetails As ListViewItem
    Dim countReceipt As Integer
    Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;data source=SS Snow.accdb")

    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

        Dim printFont As New Font("Cambria", 17, FontStyle.Regular)
        Dim headingFont As New Font("Cambria", 18, FontStyle.Bold)
        Dim sngLineHeight As Single = printFont.GetHeight + 2
        Dim sngXLocation As Single = e.MarginBounds.Left
        Dim sngYLocation As Single = e.MarginBounds.Top

        'set up header
        e.Graphics.DrawString("===============================================", headingFont, Brushes.Black, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight
        e.Graphics.DrawString(vbTab & vbTab & Space(3) & "SS Snow Furniture Sdn Bhd" & vbTab & vbTab, headingFont, Brushes.DarkSlateBlue, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight
        sngYLocation += sngLineHeight
        e.Graphics.DrawString(vbTab & vbTab & vbTab & Space(6) & "Receipt" & vbTab & vbTab, headingFont, Brushes.DarkSlateBlue, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight
        sngYLocation += sngLineHeight

        e.Graphics.DrawString("Product Name" & Space(57) & Space(9) & "Amount(RM)", headingFont, Brushes.Purple, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight
        sngYLocation += sngLineHeight

        '  set up detail
        For i As Integer = 0 To lvwProduct.Items.Count - 1
            e.Graphics.DrawString(lvwProduct.Items(i).Text & vbTab & vbTab & lvwProduct.Items(i).SubItems(1).Text & vbTab & lvwProduct.Items(i).SubItems(2).Text, printFont, Brushes.DimGray, sngXLocation, sngYLocation)
            sngYLocation += sngLineHeight
        Next

      

        ''If txtProductName.TextLength > 28 Then
        ''    e.Graphics.DrawString(txtProductName.Text & vbTab & vbTab & lblWarrantyFee.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
        ''    sngYLocation += sngLineHeight
        ''ElseIf txtProductName.TextLength > 18 And txtProductName.TextLength < 28 Then
        ''    e.Graphics.DrawString(txtProductName.Text & vbTab & vbTab & vbTab & Space(15) & lblWarrantyFee.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
        ''    sngYLocation += sngLineHeight
        ''Else
        ''    e.Graphics.DrawString(txtProductName.Text & vbTab & vbTab & vbTab & vbTab & vbTab & Space(6) & lblWarrantyFee.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
        ''    sngYLocation += sngLineHeight
        ''End If

        e.Graphics.DrawString("Delivery Fee" & vbTab & vbTab & vbTab & vbTab & vbTab & Space(8) & lblDeliveryFee.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight
        e.Graphics.DrawString(vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & Space(4) & "----------", printFont, Brushes.Crimson, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight
        e.Graphics.DrawString("Total Amount" & vbTab & vbTab & vbTab & vbTab & vbTab & Space(8) & lblTotal.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight
        e.Graphics.DrawString("Amount Payment" & vbTab & vbTab & vbTab & vbTab & vbTab & Space(6) & "(" & lblPaid.Text & ")", printFont, Brushes.Crimson, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight
        e.Graphics.DrawString(vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & Space(4) & "----------", printFont, Brushes.Crimson, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight
        e.Graphics.DrawString("Balance" & vbTab & vbTab & vbTab & vbTab & vbTab & Space(24) & lblBalance.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight


        sngYLocation += sngLineHeight
        e.Graphics.DrawString(vbTab & vbTab & Space(4) & "**Have a Nice Day**" & vbTab & vbTab, headingFont, Brushes.LightCoral, sngXLocation, sngYLocation)
        sngYLocation += sngLineHeight
        e.Graphics.DrawString("===============================================", headingFont, Brushes.Black, sngXLocation, sngYLocation)


    End Sub

    Private Sub frmPrintCash_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'SS_SnowDataSet.Receipt_Item' table. You can move, or remove it, as needed.
        Me.Receipt_ItemTableAdapter.Fill(Me.SS_SnowDataSet.Receipt_Item)
        'TODO: This line of code loads data into the 'SS_SnowDataSet.Receipt' table. You can move, or remove it, as needed.
        Me.ReceiptTableAdapter.Fill(Me.SS_SnowDataSet.Receipt)
        'Dim ReceiptID As StreamReader
        'ReceiptID = New StreamReader("ReceiptNo.txt")

        'Do Until ReceiptID.EndOfStream
        '    ReceiptID.ReadLine()
        '    countReceipt = countReceipt + 1
        'Loop
        'txtReceiptNo.Text = "RE" & countReceipt.ToString("0000")
        'ReceiptID.Close()

        ' txtReceiptNo.Text = frmSumOrderCash.txtReceiptNo.Text

    End Sub

    Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click

        With PrintPreviewDialog1
            .Document = PrintDocument1
            .ShowDialog()
        End With

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        'con.Open()

        '' For i As Integer = 0 To lvwProduct.Items.Count - 1

        'Dim ReceiptItemNo As OleDbCommand = New OleDbCommand("SELECT * FROM [Receipt Item] WHERE ReceiptID = '" & txtReceiptNo.Text & "'", con)
        'Dim ReceiptItemEr As OleDbDataReader = ReceiptItemNo.ExecuteReader()
        'Dim ReceiptNo As OleDbCommand = New OleDbCommand("SELECT * FROM [Receipt] WHERE ReceiptID = '" & txtReceiptNo.Text & "'", con)
        'Dim ReceiptER As OleDbDataReader = ReceiptNo.ExecuteReader()

        'While ReceiptItemEr.Read()
        '    ListDetails = lvwProduct.Items.Add(ReceiptItemEr("ProName"))
        '    ListDetails.SubItems.Add(ReceiptItemEr("ProQty"))
        '    ListDetails.SubItems.Add(ReceiptItemEr("UnitPrice"))
        'End While

        'While ReceiptER.Read()
        '    lblTotal.Text = ReceiptER("ReceiptAmount")
        '    lblDiscount.Text = ReceiptER("Discount")
        '    lblDeliveryFee.Text = ReceiptER("DeliveryFee")
        '    lblAmount.Text = lblTotal.Text - lblDiscount.Text + lblDeliveryFee.Text
        '    lblPaid.Text = frmSumOrderCash.lblPaid.Text
        '    lblBalance.Text = frmSumOrderCash.lblBalance.Text
        'End While


        ''  Next
        'con.Close()

        For x As Integer = 0 To SS_SnowDataSet.Receipt_Item.Rows.Count - 1
            If txtReceiptNo.Text = SS_SnowDataSet.Receipt_Item.Rows(x).Item(0) Then
                ListDetails = lvwProduct.Items.Add(SS_SnowDataSet.Receipt_Item(x).Item(2))
                ListDetails.SubItems.Add(SS_SnowDataSet.Receipt_Item(x).Item(3))
                ListDetails.SubItems.Add(SS_SnowDataSet.Receipt_Item(x).Item(4))
            End If
        Next x


        For w As Integer = 0 To SS_SnowDataSet.Receipt.Rows.Count - 1
            If txtReceiptNo.Text = SS_SnowDataSet.Receipt.Rows(w).Item(0) Then
                lblAmount.Text = SS_SnowDataSet.Receipt.Rows(w).Item(1)
                lblDiscount.Text = SS_SnowDataSet.Receipt.Rows(w).Item(2)
                lblDeliveryFee.Text = SS_SnowDataSet.Receipt.Rows(w).Item(3)
                lblTotal.Text = SS_SnowDataSet.Receipt.Rows(w).Item(4)
                lblPaid.Text = SS_SnowDataSet.Receipt.Rows(w).Item(5)
                lblBalance.Text = SS_SnowDataSet.Receipt.Rows(w).Item(6)
            End If
        Next w


    End Sub

    Private Sub ReceiptBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Validate()
        Me.ReceiptBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.SS_SnowDataSet)

    End Sub
End Class


回复

使用道具 举报

39

主题

1

好友

3143

积分

本站名嘴

Rank: 11Rank: 11

4#
发表于 2013-7-18 07:51 PM |只看该作者
tomiverson 发表于 2013-7-18 12:07 PM
可以把你中error的code放出来看看吗?

如果再start up 是set这个form先跑的话。。。就没有问题~但是如果从前面开始的话。。。就error了~


回复

使用道具 举报

0

主题

0

好友

106

积分

高级会员

Rank: 3Rank: 3Rank: 3

5#
发表于 2013-7-19 08:17 AM |只看该作者
~美妹一號~ 发表于 2013-7-18 07:51 PM
如果再start up 是set这个form先跑的话。。。就没有问题~但是如果从前面开始的话。。。就error了~

google 了一下,感觉是它要read的那个object在你要用的时候不存在。

或许你应该用debug mode一个line一个line的来debug看是那一个line弄到这个问题出来?


回复

使用道具 举报

39

主题

1

好友

3143

积分

本站名嘴

Rank: 11Rank: 11

6#
发表于 2013-7-20 04:10 AM |只看该作者
tomiverson 发表于 2013-7-19 08:17 AM
google 了一下,感觉是它要read的那个object在你要用的时候不存在。

或许你应该用debug mode一个line一 ...

解决了~谢谢~


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-12-26 03:29 PM , Processed in 0.109496 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部