SHARE
TWEET

Untitled

a guest Nov 14th, 2017 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '  Private conn As SqlConnection
  2. Private DA As SqlDataAdapter
  3. Private DS As System.Data.DataSet
  4. Private CB As SqlCommandBuilder
  5. Private ROW As DataRow
  6.  
  7. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  8.     If Not IsPostBack Then
  9.         Call GETNWDS()
  10.         ' updateprogrammaly
  11.         ContactNamebox.Text = Now
  12.         'Call UpdateNWDS()
  13.     End If
  14. End Sub
  15.  
  16. Public Sub GETNWDS()
  17.     '' opencustumorDataAdapterdaaset DS
  18.  
  19.     Dim connectionString = ConfigurationManager.ConnectionStrings("NW testConnectionString").ConnectionString
  20.     Dim queryString As String = "SELECT CustomerID, CompanyName, ContactName FROM Customers where CustomerID='ALFKI'"
  21.  
  22.     Dim conn As New SqlConnection(connectionString)
  23.     DA = New SqlDataAdapter(queryString, conn)
  24.     DS = New System.Data.DataSet
  25.     DA.Fill(DS)
  26.     Dim DT As DataTable = DS.Tables(0)
  27.     ROW = DT(0)
  28.  
  29.     CustomerIDbox.Text = ROW("CustomerID").ToString
  30.     CompanyNamebox.Text = ROW("CompanyName").ToString
  31.     ContactNamebox.Text = ROW("ContactName").ToString
  32. End Sub
  33.  
  34. Public Sub UpdateNWDS()
  35.     'TODO Complete update code
  36.     'update-HOW TO SAVE CHANES IN ds AND UODATE DB???????---------
  37.  
  38.     '  ROW("ContactName") = ContactNamebox.Text      'LKE THIS??????
  39.  
  40.     CB = New SqlCommandBuilder(DA)
  41.    
  42. Try
  43.  
  44.         'Update the database using the data adapter
  45.         DA.Update(DS)
  46.  
  47.     Catch x As Exception
  48.         ' Error during Update, add code to locate error, reconcile
  49.         ' and try to update again.
  50.     End Try
  51.  
  52.  
  53. End Sub
  54.  
  55.  
  56. Protected Sub SaveButton_Click(sender As Object, e As EventArgs) Handles Me.Load
  57.     Call UpdateNWDS()
  58. End Sub
RAW Paste Data
Top