تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
AccessViolationException was unhandled error
#1
,Hi everyone

:I'm facing an issue in my project every time that I'm trying to use "openfiledialog", and you can see the issue below
[ATTACH=CONFIG]1218[/ATTACH]

:And I have the following
.I had "Login Form", and I deleted it

.Changed the startup form to the MDIParent

!Debug the project and it's worked just fine

:The "Login Form" is
[ATTACH=CONFIG]1219[/ATTACH]

:And the code of the "Login Form" is
كود :
Imports System.Data.OleDb
Public Class LoginFrm

    Private Sub LoginFrm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        If UsersCount() = True Then
            MsgBox("There is no user in your system, you will be redirected to another form to add new user.", MsgBoxStyle.Information, "Login")
            AddUserFrm.MdiParent = MainFrmvb
            AddUserFrm.Show()
            'Me.Hide()
            Me.Close()
            Exit Sub
        End If
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If Me.TextBox1.Text = "" Then
            MsgBox("You should enter the user name", vbOKOnly, "Login")
            Exit Sub
        ElseIf Me.TextBox2.Text = "" Then
            MsgBox("You should enter the password", vbOKOnly, "Login")
            Exit Sub
        ElseIf Me.TextBox1.Text = "Administrator" AndAlso Me.TextBox2.Text = "Administrator" Then ' this code I should remove it from here
            AfterLogin.MdiParent = MainFrmvb
            AfterLogin.Show()
            'Me.Hide()
            Me.Close()
        Else
            If UserLoggedIn() = True Then
                MsgBox("Wrong username or password", vbCritical, "Login")
            Else
                'checkpermissions()
                MsgBox("You logged in successfully", vbInformation, "Login")
                AfterLogin.Label1.Text = test()
                AfterLogin.MdiParent = MainFrmvb
                AfterLogin.Show()
                'Me.Hide()
                Me.Close()
            End If
        End If
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Application.Exit()
    End Sub
    Function UsersCount()
        ' get the password from the database
        Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
        Dim TB = DA.User_Count
        If TB = 0 Then
            Return True
        Else
            Return False
        End If
    End Function
    Function UserLoggedIn()
        ' get the password from the database
        Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
        Dim TB = DA.GetDataByUserNamePass(Trim(Me.TextBox1.Text), Trim(Me.TextBox2.Text))
        If TB.Rows.Count = 0 Then
            Return True
        Else
            Return False
        End If
    End Function
    Function test()
        Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
        Dim TBS = DA.GetDataByUserNamePass(Trim(Me.TextBox1.Text), Trim(Me.TextBox2.Text))
        Return TBS.Rows(0).Item(1)
    End Function
End Class



:I searched all the code, and I did the following
كود :
Private Sub LoginFrm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'If UsersCount() = True Then
        MsgBox("There is no user in your system, you will be redirected to another form to add new user.", MsgBoxStyle.Information, "Login")
        AddUserFrm.MdiParent = MainFrmvb
        AddUserFrm.Show()
        Me.Hide()
        'Me.Close()
        'Exit Sub
        'End If
End Sub

!If you noticed that I canceled the calling of the function "UsersCount()" and everything works fine

.I don't know what is the problem in that function

?Do you have any suggestion for me

.I'll appreciate it

.Best


الملفات المرفقة صورة/صور
       
الرد }}}}
تم الشكر بواسطة:
#2
try change your code to

PHP كود :
if openfiledialog.showdialog=dialogresulut.ok then
'your code here
end if 
i couldnot understand your code here
are you trying to get count of recods inside the table
?
PHP كود :
Function UsersCount()
        
' get the password from the database
        Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
        Dim TB = DA.User_Count
        If TB = 0 Then
            Return True
        Else
            Return False
        End If
    End Function 
kindly inform me about objects used in this function

best regards
الرد }}}}
تم الشكر بواسطة:
#3
,Hi bro
.Thanks for replying me
:The following code is about a query in the Dataset that counts the users in the Users_Table


()Function UsersCount
get the password from the database
Dim DA
As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
Dim TB
= DA.User_Count
If TB = 0 Then
Return True
Else
Return
False
End
If
End Function


The problem is not in the (OpenFileDialog), it is in calling of these two (Functions -UsersCount- and -UserLoggedIn-) as I think but I'm not sure.

And the Function UserLoggedIn is to check if the user entered the correct username and password that were stored in the Users_Table.

I hope you got all the information that could help you to understand my issue.

I'll appreciate your help.
Best.
الرد }}}}
تم الشكر بواسطة:
#4

,Hi hoob computer

"Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt”

: This issue shouldn't happen in managed code
You can try setting Visual Studio Debugger to bypass this exception

"Tools menu ->Options -> Debugging -> General -> Uncheck this option "Suppress JIT optimization on module load


I hope this will be helpful to your issue.

Best regards,

الرد }}}}
تم الشكر بواسطة:
#5
.Hi Abdullah, Thanks for your reply
.I did what you said, but the issue still appears

?I think that issue is happening because I'm calling two queries from one table (Users_Table) and one TableAdapter, don't you think that

?So, what is the solution for that issue
الرد }}}}
تم الشكر بواسطة:
#6
check the attached file it may help you to solve your issue


الملفات المرفقة
.rar   TestProject.rar (الحجم : 153.26 ك ب / التحميلات : 18)
الرد }}}}
تم الشكر بواسطة:
#7
.Hi amgadtamer, thanks for your reply
:I used the following code

PHP كود :
Dim da As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
        Dim counter 
As Integer
        
If da.GetDataByUserNamePass(Trim(LoginFrm.TextBox1.Text), Trim(LoginFrm.TextBox2.Text)).HasErrors Then
            counter 
0
        
Else
            
counter CInt(da.GetDataByUserNamePass(Trim(LoginFrm.TextBox1.Text), Trim(LoginFrm.TextBox2.Text)).Rows.Count)
        
End If
        If 
counter 0 Then
            
Return False
        
Else
            Return 
True
        End 
If
    
End Function

    Public Function 
UsersCount()
        
Dim da As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter '.USERSTBTableAdapter
        Dim counter As Integer
        If da.User_Count.HasValue Then
            counter = CInt(da.User_Count)
        Else
            counter = 0
        End If
        If counter <> 0 Then
            Return False
        Else
            Return True
        End If
    End Function 
.but the issue still appears
?what should I do
الرد }}}}
تم الشكر بواسطة:
#8
. I attached the project to let you see the issue
.when I click on Open File or on the Done (Button1) in the AfterLogin.Frm form, I got the issue too

?So, what do you suggest


الملفات المرفقة
.zip   HR Management System - Copy.zip (الحجم : 3.18 م ب / التحميلات : 19)
الرد }}}}
تم الشكر بواسطة:
#9
your project run on my pc without any errors
:confused:
الرد }}}}
تم الشكر بواسطة:
#10
?Really
?Why isn't it run on my computer without errors
?Did you try to run the OpenFileDialog

.Before I called the UserLoggedIn, it was working fine
.I tried to remove that function and create another one, but nothing happened and the issue still appears

.I've even created a new project and put everything in it, but the same issue appeared again

.I have another projects, they run fine on my computer

?So, what do you suggest to me
الرد }}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [VB.NET] حل مشكلة Operation Must Use An Updateable Query error EHAB.NET 0 168 07-05-16, 04:52 AM
آخر رد: EHAB.NET
  [VB.NET] مشكلة StackOverflowException was unhandled فى الليست بوكس الماجيك مسعد 35 922 03-02-16, 05:10 AM
آخر رد: الماجيك مسعد
  [VB.NET] ارجو المساعدة Syntax error in FROM clause 0theghost0 3 361 29-12-14, 02:31 AM
آخر رد: سعود
  [سؤال] Error Syntax Insert Into" djelloul 10 662 16-08-14, 05:45 PM
آخر رد: djelloul
  [سؤال] مشكلة error :: Too many arguments raydbox 1 498 28-12-13, 11:55 PM
آخر رد: Aly El-Haddad
  مشكلة في الفورم بعد ما تم اعدادة يظهر Error aftfm 5 960 10-11-12, 09:01 AM
آخر رد: SaLoOoMX

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم