Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.80 KB | None | 0 0
  1. Imports System.Data
  2. Imports System.Data.OleDb
  3. Imports System.Data.SqlClient
  4.  
  5.  
  6. Public Class demoform
  7.     Dim pass As String
  8.     Dim user As String
  9.  
  10.     Dim dr As DataRow
  11.     Dim dt As DataTable
  12.     Dim dsResult As New DataSet
  13.     Dim TableView As DataView
  14.     Dim objDataAdapter As SqlDataAdapter
  15.     Dim sConnection As String
  16.     Dim cmdBuilder As SqlCommandBuilder
  17.     Dim bs As BindingSource
  18.  
  19.     Private Sub demoform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  20.  
  21.         LoginDialog.ShowDialog()
  22.  
  23.  
  24.         sConnection = "Server=PRESONIC-PC\FUNSQL;Database=pre_accounting;Uid=" & user & "; Pwd=" & pass & ";"
  25.        
  26.         objDataAdapter = New SqlDataAdapter("SELECT * FROM dbo.medtype", sConnection)
  27.  
  28.         bs = New BindingSource
  29.  
  30.         If Not IsNothing(objDataAdapter) Then
  31.  
  32.  
  33.             ' in order to use command builder, there must be a primary key in the table
  34.             cmdBuilder = New SqlCommandBuilder(objDataAdapter)
  35.  
  36.  
  37.             objDataAdapter.Fill(dsResult)
  38.  
  39.  
  40.             TableView = dsResult.Tables(0).DefaultView
  41.             dgvplay.DataSource = TableView
  42.  
  43.  
  44.             TextBox1.DataBindings.Add(New Binding("Text", dsResult.Tables(0), "med_name"))
  45.  
  46.  
  47.  
  48.         End If
  49.  
  50.  
  51.     End Sub
  52.  
  53.  
  54.     Public Sub userpass_pass(ByVal the_user As String, ByVal the_pass As String)
  55.         user = the_user
  56.         pass = the_pass
  57.     End Sub
  58.  
  59.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  60.  
  61.        objDataAdapter.Update(dsResult, dsResult.Tables(0).TableName)
  62.  
  63.     End Sub
  64.  
  65.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  66.  
  67.         'dr = dsResult.Tables(0).Rows(1)
  68.        
  69.     End Sub
  70. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement