Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.SqlClient
- Public Class Form1
- Public SQLCon As New SqlConnection("Data Source=resolveitserver\sql;Initial Catalog=InternetServices;Persist Security Info=True;User ID=sa;Password=WorldCup2010")
- Public SQLDA As New SqlDataAdapter("select Count(SMCFunction) AS FunctCount FROM SMCFunction WHERE SMCProcessed = '0' and SMCSiteID = '3'", SQLCon)
- Public SQLDS As New DataSet
- Dim SQLCmd As SqlCommand
- Dim SQLDR As SqlDataReader
- Dim countitems As String
- Public cn As New SqlConnection("Data Source=resolveitserver\sql;Initial Catalog=InternetServices;Persist Security Info=True;User ID=sa;Password=WorldCup2010")
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'Try
- ' SQLCon.Open()
- ' SQLCmd = New SqlCommand("select Count(SMCFunction) AS FunctCount FROM SMCFunction WHERE SMCProcessed = '0' and SMCSiteID = '3'", SQLCon)
- ' 'SQLDA.Fill(SQLDS, "FunctCount")
- ' SQLDR = SQLCmd.ExecuteReader
- ' 'dg.DataSource = SQLDS.Tables("FunctCount")
- ' 'countitems = SQLDS.Tables.Item(1).ToString
- ' 'MsgBox(countitems)
- ' While SQLDR.Read
- ' MsgBox(SQLDR("FunctCount").ToString)
- ' End While
- 'Catch
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim name As String
- Dim cmd As New SqlCommand
- ' 'catch on error
- 'End Try
- 'SQLDR.Close()
- 'SQLCon.Close()
- With cmd
- .CommandType = CommandType.Text
- .CommandText = "select * from users where uusername = 'bob'"
- ' MsgBox(.CommandText)
- .Connection = cn
- ' MsgBox("Open Connection")
- .Connection.Open()
- ' MsgBox("Run Data reader")
- Dim dr As SqlDataReader = .ExecuteReader
- ' Do Until dr.Read = False
- ' MsgBox(dr.Read.ToString)
- If dr.Read Then
- name = dr(0)
- MsgBox(dr("UUsername") & " / " & dr("UPassword"))
- Else
- name = "Not Found"
- MsgBox(dr(0))
- End If
- ' Loop
- 'release resources
- .Connection.Close()
- .Dispose()
- End With
- 'MsgBox("Count: " & name)
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Dim cmd As New SqlCommand
- With cmd
- .CommandType = CommandType.Text
- .CommandText = "update users set UUsername = 'Benji4' where Uusername = 'Benji'"
- ' MsgBox(.CommandText)
- .Connection = cn
- ' MsgBox("Open Connection")
- .Connection.Open()
- Dim dr As SqlDataReader = .ExecuteReader
- .Connection.Close()
- .Dispose()
- End With
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement