User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 397,646 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,382 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 160 | Replies: 0
Join Date: Apr 2008
Posts: 30
Reputation: gabanxx is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
gabanxx gabanxx is offline Offline
Light Poster

in need of serious help here....

  #1  
May 12th, 2008
i've create a program that contain a 4 textbox and three action button. the textbox are used to fill user name, date of birth, hobbies and number. while the action button are submit upadte and clear...all of this are working perfectly..i also manage to store all the data entered by user in sql server 2000 db. the data also will display itself when the program started. the problem is now when i want to update the data i had to close te program first and start it back then the updated data will appear. what i want is the data will be outomatically updated when i click the update button. i really seek help here i hope my problem is clear enough...plzzzz oo want more thing i want to add a delete button that will outomatically delete the data...below is the program i'have being working on...i hope anyone out there reading this threat can help me solve the problem...im just a nwbz... i will apreciate alot any help...thanks in advance.....


this is use to update the data
Private Sub Update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim varCommand As New SqlCommand

Dim varAdapter As SqlDataAdapter

Try
varConnection = New SqlConnection("Server=(local);user id=sa;password=;Initial Catalog=ROP1") 'STEP 1
varConnection.Open()
varQuery = "UPDATE tbl_rop SET Name_User ='" & Trim(TextBox1.Text) & "', Date_of_birth= '" & Trim(TextBox2.Text) & "' , Hobbies='" & Trim(TextBox3.Text) & "' , Phone_Number ='" & Trim(TextBox4.Text) & "' where Name_User = '" & Trim(TextBox1.Text) & "'"
varCommand = New SqlCommand(varQuery, varConnection)
varCommand.CommandTimeout = 9999 'STEP 4
varCommand.ExecuteNonQuery() 'STEP 5

varCommand.Dispose() 'STEP 6
varConnection.Close() 'STEP 7

Catch ex As Exception
varConnection.Open()
'varConnection = New SqlConnection("Server=(local);user id=sa;password=;Initial Catalog=ROP1")

Dim sql As String
sql = "SELECT * FROM tbl_rop"
'varCommand = New SqlCommand(sql, varConnection)
varAdapter = New SqlDataAdapter(varCommand)


varAdapter.Fill(varDataSet)
TextBox1.Text = varDataSet.Tables(0).Rows(0).Item("Name_User")
TextBox2.Text = varDataSet.Tables(0).Rows(0).Item("Date_of_birth")
TextBox3.Text = varDataSet.Tables(0).Rows(0).Item("Hobbies")
TextBox4.Text = varDataSet.Tables(0).Rows(0).Item("Phone_Number")

varConnection.Close()

End Try



End Sub





this is used to delete the data which nothing seem to be working help mw find the problem


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

MsgBox("are you sure want to delete?, important information will be erase. ")
varConnection = New SqlConnection("Server=(local);user id=sa;password=;Initial Catalog=ROP1") 'STEP 1
varConnection.Open() 'STEP 2
varQuery = "DELETE FROM tbl_rop WHERE Name_User ='" & TextBox1.Text & "', Date_of_birth= '" & TextBox2.Text & "' , Hobbies='" & TextBox3.Text & "' , Phone_Number ='" & TextBox4.Text & "'" 'STEP 3
varCommand = New SqlCommand(varQuery, varConnection)

varCommand.ExecuteNonQuery()

varCommand.Dispose() 'STEP 6
varConnection.Close() 'STEP 7

End Sub
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb VB.NET Marketplace
Thread Tools Display Modes

Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 11:08 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC