Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data
- Imports System.Data.SqlClient
- Module iQuery
- Public Sub Mssql_Connection(dBase As String, query As String)
- Dim con As New SqlConnection
- Dim cmd As New SqlCommand
- Dim X As Integer
- Dim User, Pass, Host As String
- Host = iMain.TextBox1.Text
- User = iMain.TextBox2.Text
- Pass = iMain.TextBox3.Text
- Try
- con.ConnectionString = "Data Source=" & Host & ";Initial Catalog=" & dBase & ";Persist Security Info=True;User ID=" & User & ";Password=" & Pass & ""
- con.Open()
- cmd = New SqlCommand(query, con)
- x = cmd.ExecuteNonQuery()
- MessageBox.Show("Rows Updated: " & x)
- Catch ex As Exception
- MessageBox.Show("Error while connecting to SQL Server." & ex.Message)
- Finally
- con.Close()
- End Try
- End Sub
- End Module
Add Comment
Please, Sign In to add comment