TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jas S
NA
1
1.7k
Hi! I am Not able to Update database through Datagridview in VB.net Pls help
Nov 13 2012 9:02 AM
Hi! I'm trying to Update the database using Datagridview in VB.net. When modify name, address, phone or mobile number and click the update button, other rows(ID) value also changed and same. Pls help me.... thanks in advance
My code is here:-
Private Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim str As String
If Not cnn.State = ConnectionState.Open Then
cnn.Open()
End If
If Me.txtID.Text & "" = "" Then
cmd.Connection = cnn
cmd.CommandText = "INSERT INTO CLIENT_REGISTER(CLIENTID,NAME,ADDRESS,PHONE,MOBILE) VALUES ('" & Me.txtID.Text & "','" & Me.txtName.Text & "','" & Me.txtAddress.Text & "','" & Me.txtPhone.Text & "','" & Me.txtMobile.Text & "')"
cmd.ExecuteNonQuery()
End If
cmd.Connection = cnn
str = "UPDATE CLIENT_REGISTER SET NAME='" & Me.txtName.Text & "',ADDRESS='" & Me.txtAddress.Text & "',PHONE='" & Me.txtPhone.Text & "',MOBILE='" & Me.txtMobile.Text & "' WHERE CLIENTID=" & Me.txtID.ReadOnly
cmd = New OleDbCommand(str, cnn)
cmd.ExecuteNonQuery()
RefreshData()
cnn.Close()
VEnable()
Me.btnSave.Enabled = False
Me.btnEdit.Enabled = False
Me.btnUpdate.Enabled = False
Me.btnCancel.Enabled = True
Me.btnNew.Enabled = True
End Sub
Reply
Answers (
1
)
Problem in exporting data to chart
how to create a method that print out the sum of 3 numbers