Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.08 KB | None | 0 0
  1. Imports System.Data.SqlClient
  2.  
  3. Public Class Form1
  4.     Public SQLCon As New SqlConnection("Data Source=resolveitserver\sql;Initial Catalog=InternetServices;Persist Security Info=True;User ID=sa;Password=WorldCup2010")
  5.     Public SQLDA As New SqlDataAdapter("select Count(SMCFunction) AS FunctCount FROM SMCFunction WHERE SMCProcessed = '0' and SMCSiteID = '3'", SQLCon)
  6.     Public SQLDS As New DataSet
  7.     Dim SQLCmd As SqlCommand
  8.     Dim SQLDR As SqlDataReader
  9.     Dim countitems As String
  10.     Public cn As New SqlConnection("Data Source=resolveitserver\sql;Initial Catalog=InternetServices;Persist Security Info=True;User ID=sa;Password=WorldCup2010")
  11.  
  12.    
  13.  
  14.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  15.         'Try
  16.         '    SQLCon.Open()
  17.         '    SQLCmd = New SqlCommand("select Count(SMCFunction) AS FunctCount FROM SMCFunction WHERE SMCProcessed = '0' and SMCSiteID = '3'", SQLCon)
  18.         '    'SQLDA.Fill(SQLDS, "FunctCount")
  19.         '    SQLDR = SQLCmd.ExecuteReader
  20.         '    'dg.DataSource = SQLDS.Tables("FunctCount")
  21.         '    'countitems = SQLDS.Tables.Item(1).ToString
  22.         '    'MsgBox(countitems)
  23.         '    While SQLDR.Read
  24.         '        MsgBox(SQLDR("FunctCount").ToString)
  25.         '    End While
  26.         'Catch
  27.  
  28.     End Sub
  29.  
  30.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  31.         Dim name As String
  32.         Dim cmd As New SqlCommand
  33.         '    'catch on error
  34.         'End Try
  35.         'SQLDR.Close()
  36.         'SQLCon.Close()
  37.  
  38.  
  39.  
  40.  
  41.  
  42.         With cmd
  43.             .CommandType = CommandType.Text
  44.  
  45.             .CommandText = "select * from users where uusername = 'bob'"
  46.  
  47.             ' MsgBox(.CommandText)
  48.             .Connection = cn
  49.             '  MsgBox("Open Connection")
  50.             .Connection.Open()
  51.             ' MsgBox("Run Data reader")
  52.             Dim dr As SqlDataReader = .ExecuteReader
  53.  
  54.             '  Do Until dr.Read = False
  55.  
  56.  
  57.        
  58.  
  59.             ' MsgBox(dr.Read.ToString)
  60.             If dr.Read Then
  61.                 name = dr(0)
  62.                 MsgBox(dr("UUsername") & " / " & dr("UPassword"))
  63.  
  64.  
  65.  
  66.             Else
  67.                 name = "Not Found"
  68.                 MsgBox(dr(0))
  69.  
  70.             End If
  71.             '  Loop
  72.  
  73.             'release resources
  74.             .Connection.Close()
  75.             .Dispose()
  76.  
  77.         End With
  78.         'MsgBox("Count: " & name)
  79.  
  80.     End Sub
  81.  
  82.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  83.         Dim cmd As New SqlCommand
  84.         With cmd
  85.             .CommandType = CommandType.Text
  86.  
  87.             .CommandText = "update users set UUsername = 'Benji4' where Uusername = 'Benji'"
  88.  
  89.             ' MsgBox(.CommandText)
  90.             .Connection = cn
  91.             '  MsgBox("Open Connection")
  92.             .Connection.Open()
  93.             Dim dr As SqlDataReader = .ExecuteReader
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.             .Connection.Close()
  101.             .Dispose()
  102.         End With
  103.  
  104.     End Sub
  105. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement