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 401,531 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 3,347 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.
Views: 993 | Replies: 3
Reply
Join Date: Mar 2008
Posts: 5
Reputation: kimhanu is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kimhanu kimhanu is offline Offline
Newbie Poster

How to update into database

  #1  
Mar 27th, 2008
I use ADO.net and SQL database . but cannot updata records into database .
Who can do it ? help me please !
my database is sv.mdf , table is huycnt include fields : id , name .
help me soon . Thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: ★ Jogja ★
Posts: 2,473
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Rep Power: 9
Solved Threads: 215
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Nearly a Posting Maven

Re: How to update into database

  #2  
Mar 27th, 2008
show use your code and effort. we will help u
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote  
Join Date: Mar 2008
Posts: 5
Reputation: kimhanu is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kimhanu kimhanu is offline Offline
Newbie Poster

Re: How to update into database

  #3  
Mar 28th, 2008
Here is code :


  1. Imports System.data.SqlClient
  2. Public Class Form1
  3. Dim s As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\csdl1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
  4. Dim connect As New SqlConnection(s)
  5. Dim da As New SqlDataAdapter
  6. Dim ds As New DataSet
  7. Dim cmd As New SqlCommand
  8. Dim them1 As Boolean = False
  9. Dim xoa As Boolean = False
  10. Dim sua As Boolean = False
  11.  
  12. Private Sub exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exit.Click
  13. End
  14. End Sub
  15.  
  16. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  17. Try
  18. connect.Open()
  19. MessageBox.Show("connect ok")
  20. Catch ex As Exception
  21. MessageBox.Show(ex.ToString)
  22. End Try
  23.  
  24. End Sub
  25.  
  26. Private Sub showdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles showdata.Click
  27. If connect.State = ConnectionState.Closed Then
  28. connect.Open()
  29. Else
  30. Dim s As String = "select * from huycnt"
  31. cmd.CommandText = s
  32. cmd.CommandType = CommandType.Text
  33. cmd.Connection = connect
  34. da.SelectCommand = cmd
  35. ds.Clear()
  36. da.Fill(ds, "huycnt")
  37. dg.DataSource = ds.Tables("huycnt").DefaultView
  38. End If
  39. connect.Close()
  40. End Sub
  41.  
  42. Private Sub add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles add.Click
  43. txtma.Focus()
  44. End Sub
  45.  
  46. Private Sub Save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Save.Click
  47.  
  48. If connect.State = ConnectionState.Closed Then
  49. connect.Open()
  50. Else
  51. Dim s As String = "insert into huycnt(id,name)values ('" + txtid.Text + "', '" + txtname.Text + "')"
  52. cmd.CommandText = s
  53. cmd.CommandType = CommandType.Text
  54. cmd.Connection = connect
  55. da.SelectCommand = cmd
  56. da.Fill(ds, "huycnt")
  57. 'MessageBox.Show("success ")
  58. da.Update(ds, "huycnt")
  59.  
  60.  
  61. dg.Refresh()
  62.  
  63.  
  64. End If
  65. connect.Close()
  66.  
  67. End Sub
  68. End Class



but records can not update into database . please help me
Last edited by WolfPack : Mar 28th, 2008 at 9:58 am. Reason: Added code tags. Use them when you post code.
Reply With Quote  
Join Date: Mar 2008
Posts: 2
Reputation: zikrullah is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zikrullah zikrullah is offline Offline
Newbie Poster

Re: How to update into database

  #4  
Mar 30th, 2008
fine ya....
Reply With Quote  
Reply

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

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

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