تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] مساعده في حل مشكلة ببرنامج vb.net
#7

Add_User.vb
-----------------------------------

Imports System.Data.OleDb

Public Class Add_User
Dim save_cmd As New OleDbCommand
Dim edit_cmd As New OleDbCommand

Private Sub Add_User_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

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

'save_cmd = New OleDbCommand("insert into usersDataSet (user-name,pass-word) values ('" & Textname.Text & "'," & Textpass.Text & ")", con)
save_cmd = New OleDbCommand("INSERT INTO users ([user-name],[pass-word]) VALUES ('" & Textname.Text & "'," & Textpass.Text & ")", con)

If con.State = ConnectionState.Closed Then con.Open()
save_cmd.ExecuteNonQuery()
con.Close()

MsgBox("تم الحفظ بنجاح")
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
edit_cmd = New OleDbCommand("update users set user-name='" & Textname.Text & "',pass-word=" & Textpass.Text & "where user-name='" & Textname.Text & ")", con)
If con.State = ConnectionState.Closed Then con.Open()
edit_cmd.ExecuteNonQuery()
con.Close()

MsgBox("تم تعديل بنجاح")
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form1.Show()
Me.Close()

End Sub
End Class



-------------------------------------


Form1.vb
------------------------------

Imports System.Data.OleDb
Public Class Form1
Dim Adapt As New OleDbDataAdapter
Dim dt As New DataTable
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dbase_conn()
End Sub

Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Add_User.Show()
Me.Hide()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Adapt = Nothing : dt.Clear()

'Adapt = New OleDbDataAdapter("Select ' from Users where user_name='" & TextBox1.Text & "'", con)
Adapt = New OleDbDataAdapter("SELECT * FROM Users WHERE [user-name]='" & TextBox1.Text & "' AND [pass-word]=" & TextBox2.Text, con)

Adapt.Fill(dt)

'If TextBox2.Text = dt.Rows.Item(0).Item("user-pass") Then
If dt.Rows.Count > 0 Then

Form2.Show()
Me.Hide()

Else
MsgBox("user name OR password incorrect")

End If

End Sub
End Class
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
RE: مساعده في حل مشكلة ببرنامج vb.net - بواسطة sami2015 - 09-01-15, 02:33 AM


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


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