تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] جلب بيانات العضو من قاعدة البيانات mysql
#1
السلام عليكم

هل هناك كود لجلب بيانات العضو
مثال : العضو يقوم بالتسجيل عن طريق البرنامج
وعندما يقوم بالدخول تظهر فقط مواضيعه
يعني لا تظهر مواضيع الاعضاء الاخرين
فقط يرى مواضيعه الخاصه

انا استخدم هذا الكود

PHP كود :
Imports MySql.Data.MySqlClient

Public Class Form1
    
'Represents an SQL statement or stored procedure to execute against a data source.
    Dim cmd As New MySqlCommand
    Dim da As New MySqlDataAdapter
    '
declare conn as connection and it will now a new connection because 
    
'it is equal to Getconnection Function
    Dim con As MySqlConnection = jokenconn()

    Public Function jokenconn() As MySqlConnection
        Return New MySqlConnection("Server=mysite.com;Port=3306;Database=mydata;Uid=myuser;Pwd=mypass;")
    End Function
    Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
        Dim sql As String
        Dim publictable As New DataTable
        Try
            '
check if the textbox is equal to nothing then it will display the message below!.
            If 
txtuname.Text "" And txtpass.Text "" Then
                MsgBox
("Password or Username Incorrect!")

            Else
                
sql "select * from users where username ='" txtuname.Text "' and password = '" txtpass.Text "'"
                'bind the connection and query
                With cmd
                    .Connection = con
                    .CommandText = sql
                End With
                da.SelectCommand = cmd
                da.Fill(publictable)
                '
check if theres a result by getting the count number of rows
                
If publictable.Rows.Count 0 Then

                    
'it gets the data from specific column and assign to the variable
                    Dim user_type, name As String
                    user_type = publictable.Rows(0).Item(1)
                    name = publictable.Rows(0).Item(2)
                    '
check if the type of user is admin
                    
If user_type "admin" Then
                        
'welcomes the user as Admiistrator
                        MsgBox("Welcome " & name & " you login as Administrator ")
                        '
set the lbllogin text to Logout 
                        lbllogin
.Text "Logout"
                        'disabled the groupbox
                        GroupBox1.Enabled = False
                        '
reset all the two textbox
                        txtuname
.Text ""
                        
txtpass.Text ""
                        'set the lblname to the specific user
                        lblname.Text = "Hi, " & name

                    ElseIf user_type = "Encoder" Then
                        MsgBox("Welcome " & name & " you login as Encoder ")
                        lbllogin.Text = "Logout"
                        GroupBox1.Enabled = True
                        txtuname.Text = ""
                        txtpass.Text = ""
                        lblname.Text = "Hi, " & name
                    Else
                        MsgBox("You login as Guest!")
                        lbllogin.Text = "Logout"
                        GroupBox1.Enabled = False
                        txtuname.Text = ""
                        txtpass.Text = ""
                        lblname.Text = "Hi, " & name
                        lbllogin.Enabled = True
                        DataGridView1.Visible = True
                    End If

                Else
                    MsgBox("Contact administrator to registered!")
                    txtuname.Text = ""
                    txtpass.Text = ""
                End If

                da.Dispose()
            End If

        Catch ex As Exception
            MsgBox(ex.Message)

        End Try
        con.Clone()

       
    End Sub

    Private Sub lbllogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbllogin.Click

        If lbllogin.Text = "Logout" Then
            lbllogin.Text = "Login"
            lblname.Text = "Hi, Guest!"
        ElseIf lbllogin.Text = "Login" Then
            GroupBox1.Enabled = True

        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GroupBox1.Enabled = True
        lbllogin.Enabled = False
        Try
            Using da As New MySqlDataAdapter("Select * from `comments`", con)
                Using dt As New DataTable
                    da.Fill(dt)
                    DataGridView1.DataSource = dt
                    If DataGridView1.Rows.Count > 0 Then
                        DataGridView1.Columns(0).HeaderText = "ID"
                        DataGridView1.Columns(0).Width = 50
                        DataGridView1.Columns(1).HeaderText = "added by"
                        DataGridView1.Columns(1).Width = 150
                        DataGridView1.Columns(2).HeaderText = "Name Thread"
                        DataGridView1.Columns(2).Width = 200
                        DataGridView1.Columns(3).HeaderText = "Notes"
                        DataGridView1.Columns(3).Width = 200
                       
                    End If
                End Using
            End Using



        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class 


هناك جدولين في قاعدة البيانات
comments
users

البيانات الموجوده في جدول comments

post_id username title message



البيانات الموجوده في جدول users

id username password



اتمنى سؤالي واضح

شكرا لكم
الرد }}}
تم الشكر بواسطة: asemshahen5
#2
نفس طريقة تسجيل الدخول يتم الاستعلام عن اسم الكاتب!
الرد }}}
تم الشكر بواسطة: asemshahen5
#3
وعليكم السلام ورحمة الله وبركاته

عند جلب مواضيع العضو يتم جلب المواضيع من جدول المواضيع بشرط معين وهو اسم العضو أو التسلسل الخاص به أو اي علامة أخرى تدل على العضو .

كل الموضوع يحصر في جملة جلب البيانات.
قال رسول الله صلى الله عليه وسلم ( من قال لا إله إلا الله دخل الجنة ) حديث صحيح.
قال رسول الله صلى الله عليه وسلم ( كلمتان خفيفتان على اللسان ثقيلتان في الميزان حبيبتان للرحمن : سبحان الله وبحمده سبحان الله العظيم ) حديث صحيح.
الرد }}}
تم الشكر بواسطة: asemshahen5


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  استعلام من عدة جداول لقاعدة بيانات اكسس Adel27213 1 702 07-11-23, 08:27 AM
آخر رد: justforit
  [سؤال] عدم إظهار الصور مع النص فى Listview من قاعدة البيانات alims 2 1,582 27-08-23, 12:22 PM
آخر رد: رضوان الجماعي
  [SQL] استفسار عن طريقة تحزم قواعد بيانات MSSQL مع البرنامج VB.NET2019 salemq 2 530 18-05-23, 03:02 AM
آخر رد: سعود
  ما معني بيانات تقع بين الرمز[] في حقل في داتا بيس bassant 3 673 03-04-23, 11:53 PM
آخر رد: sanyor77
  [نقاش] مشاركة قاعدة بيانات SQL على شبكه داخليه morkoskhalaf 3 3,012 06-01-23, 03:20 AM
آخر رد: عبدالكريم برشدان
  قاعدة بيانات xml djelloul 3 2,799 07-11-22, 10:27 PM
آخر رد: Am7
  [عنوان معدل]حفظ بيانات listbox fhad24 36 12,241 08-10-22, 06:55 PM
آخر رد: رضوان الجماعي
  استفسار عن تخزين الوقت في قاعدة البيانات strongriseman 2 1,128 22-04-22, 07:27 PM
آخر رد: strongriseman
  [سؤال] مشكلة فى عرض الصورة من ادخل قاعدة البيانات alims 2 1,266 17-11-21, 10:09 AM
آخر رد: سعود
  استعلام يرجع اسماء الاعمدة و نوع البيانات في جدول معين بسام محمدغانم 0 964 23-10-21, 01:43 AM
آخر رد: بسام محمدغانم

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


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