|
-
Jul 29th, 2004, 08:53 PM
#1
Thread Starter
New Member
about Update Button
hi, now i'm doing change password form but i try a lot of sample already but still can't work , who can show me the example.
this is my code can u check for me thank you!!!
Imports System.Data.SqlClient
Public Class Form2
Inherits System.Windows.Forms.Form
Dim cn As New SqlConnection
Dim da As New SqlDataAdapter
Dim cm As New SqlCommand
Dim ds As New DataSet
Dim dsEmp As New DataSet
Dim cmEmp As New SqlCommand
Dim SQLstr As String
Dim RowNo As Integer = 0
Dim i As Integer
Dim cm1 As CurrencyManager
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn.ConnectionString = "data source=(local);integrated security=SSPI;initial catalog=videosystem;"
cn.Open()
cmEmp.Connection = cn
cmEmp.CommandText = "select * from Employees"
da.SelectCommand = cmEmp
da.Fill(dsEmp, "Employees")
cm.Connection = cn
ds.Clear()
SQLstr = "select * from Employees where UserName ='" & str & "'"
cm.CommandText = SQLstr
da.SelectCommand = cm
da.Fill(ds, "Pass")
cm1 = Me.BindingContext(ds, "Pass")
RefreshData()
Dim i As Integer
da.Fill(ds, "Employees")
da.SelectCommand.CommandText = "select * from Employees where UserName= '" & TextBox1.Text & "'"
da.UpdateCommand = New Data.SqlClient.SqlCommand
End Sub
Sub RefreshData()
TextBox1.Text = ds.Tables("Pass").Rows(cm1.Position)(0)
TextBox2.Text = ds.Tables("Pass").Rows(cm1.Position)(1)
TextBox2.Focus()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
da.UpdateCommand.Connection = cn
da.UpdateCommand.CommandText = "update Employees set Password = '" & TextBox2.Text & "'"
Try
da.UpdateCommand.ExecuteNonQuery()
ds.Clear()
da.Fill(ds, "Employees")
Catch Ex As Exception
End Try
cn.Close()
Me.Close()
End Class
-
Jul 30th, 2004, 01:13 AM
#2
Re: about Update Button
da.UpdateCommand.CommandText = "update Employees set Password = '" & TextBox2.Text & "'"

Are you sure you want to set everyone's password to the same thing?
-
Jul 30th, 2004, 02:39 AM
#3
Thread Starter
New Member
no every 1 i want different password
hi i'm new i dot net
no i don't want the every one same password ,
if i want different for every 1 so what are the coding i need !!!
i think this way may work direct use sql update statement but now i still find the coding ...
can u show me the coding ? thank you
-
Jul 30th, 2004, 03:51 AM
#4
Just add a WHERE username = .... like in your first SQL query there.
-
Jul 30th, 2004, 04:04 AM
#5
Thread Starter
New Member
i try already
hi i'm try already but the problem now is in the sql database table still a old data won't be change and when execute the form will display the right 1 but database table won't be change.
when i add username = textbox2.text then all is not working but no display error.
-
Jul 31st, 2004, 05:50 AM
#6
Re: i try already
Originally posted by steven2u
hi i'm try already but the problem now is in the sql database table still a old data won't be change and when execute the form will display the right 1 but database table won't be change.
when i add username = textbox2.text then all is not working but no display error.
I'm sorry, but HUH?
Can you rephrase that and try explaining again?
-
Jul 31st, 2004, 06:46 AM
#7
Frenzied Member
well i think the real challenge is to understand his words first
LOL
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|