تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] تصحيح الكود لو سمحتم
#4
اولا : غير اسم الجدول user  إلى users
ثانيا الكود كالتالي بعد تصحيح بعض النقاط


PHP كود :
Imports System.Data.OleDb
Public Class frmUser
    Dim cn 
As New OleDbConnection
    Dim mytable 
As DataTable
    Dim da 
As New OleDbDataAdapter
    Dim cmd 
As New OleDb.OleDbCommand
    Dim RD 
As OleDbDataReader

    Private Sub btnExit_Click
(ByVal sender As ObjectByVal e As EventArgsHandles btnExit.Click
        Application
.Exit()
 
   End Sub

    Private Sub btnLogin_Click
(ByVal sender As ObjectByVal e As EventArgsHandles btnLogin.Click
        If txtUserName
.Text.Length <= Or txtPassword.Text.Length <= 0 Then
            MessageBox
.Show("Please Enter UserName or Password""Error"MessageBoxButtons.OKMessageBoxIcon.Error)
 
       Else
            cn 
= New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database1.accdb;Persist Security Info=False;")

 
           cn.Open()



 
           cmd = New OleDbCommand("select * from [Users] where [UserName]= '" txtUserName.Text.ToString() & "' and [Password]='" txtPassword.Text.ToString() + "'"cn)


 
           RD cmd.ExecuteReader()

 
           mytable = New DataTable()
 
           mytable.Load(RD)

 
           cn.Close()

 
           If mytable.Rows.Count 0 Then
                
'lblerror.Show()
                txtUserName.Text = ""
                txtPassword.Text = ""
                txtUserName.SelectAll()
            Else
                Dim F1 As New Form1
                F1.Show()
                Me.Hide()
            End If
            If txtUserName.Text = vbNullString Or txtPassword.Text = vbNullString Then
                MsgBox("لم تقم بإدخال أسم المستخدم أو كلمة المرور ")
                Exit Sub
            End If

            If cn.State = ConnectionState.Open Then cn.Close()
            cn.Open()
            cmd.Connection = cn
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "SELECT count(userid) from users where username = '" & txtUserName.Text & "'"
            If cmd.ExecuteScalar.ToString = 0 Then
                MsgBox("أسم المستخدم أو كلمة المرور خطأ !")
                Exit Sub
            End If
            cn.Close()

            If cn.State = ConnectionState.Open Then cn.Close()
            cn.Open()
            cmd.Connection = cn
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "SELECT * FROm users where username = '" & txtUserName.Text & "'"
            RD = cmd.ExecuteReader
            RD.Read()
            If RD.Item("username") = txtUserName.Text And RD.Item("password") = txtPassword.Text Then
                Form1.Show()
                Me.Hide()
            Else
                MsgBox("أسم المستخدم أو كلمة المرور غير صحيحة ")
                Exit Sub
            End If

            Form1.Button1.Visible = False
            Form1.Button2.Visible = False
            Form1.Button3.Visible = False
            Form1.Button4.Visible = False
            Form1.Button5.Visible = False
            Form1.Button6.Visible = False
            Form1.Button7.Visible = False
            Form1.Button8.Visible = False

            If RD.Item("c1") = True Then
                Form1.Button1.Visible = True
            End If

            If RD.Item("c2") = True Then
                Form1.Button2.Visible = True
            End If

            If RD.Item("c3") = True Then
                Form1.Button3.Visible = True
            End If

            If RD.Item("c4") = True Then
                Form1.Button4.Visible = True
            End If

            If RD.Item("c5") = True Then
                Form1.Button5.Visible = True
            End If

            If RD.Item("c6") = True Then
                Form1.Button6.Visible = True
            End If

            If RD.Item("c7") = True Then
                Form1.Button7.Visible = True
            End If

            If RD.Item("c8") = True Then
                Form1.Button8.Visible = True
            End If

        End If

    End Sub

    Private Sub frmUser_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        cn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database1.accdb;Persist Security Info=False;")
    End Sub
End Class 
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
تصحيح الكود لو سمحتم - بواسطة 0theghost0 - 29-08-17, 12:55 PM
RE: تصحيح الكود لو سمحتم - بواسطة Jounior_P - 29-08-17, 01:38 PM
RE: تصحيح الكود لو سمحتم - بواسطة 0theghost0 - 29-08-17, 01:47 PM
RE: تصحيح الكود لو سمحتم - بواسطة Jounior_P - 29-08-17, 02:54 PM
RE: تصحيح الكود لو سمحتم - بواسطة 0theghost0 - 30-08-17, 12:06 PM


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


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