HOW TO CREATE USERS IN SQL SERVER WITH VB.NET
CREATE LOGIN " & UserID & " WITH PASSWORD=N'" &
Password & ", DEFAULT_DATABASE=[" & SQLDatabaseName & "], CHECK_EXPIRATION=OFF,
CHECK_POLICY=OFF"
Ex:
ExecuteSQLQuery(Query)
Execute SQL Command with single function
Public Function ExecuteSQLQuery(ByVal SQLQueryString As String) As Boolean
Dim err As Boolean = True
Dim SqlConn As New SqlClient.SqlConnection
Dim Sqlcmmd As New SqlClient.SqlCommand
Try
SqlConn.ConnectionString = ConnectionStrinG
SqlConn.Open()
Sqlcmmd.Connection = SqlConn
Sqlcmmd.CommandText = SQLQueryString
Sqlcmmd.CommandType = CommandType.Text
Sqlcmmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
err = False
Finally
SqlConn.Close()
SqlConn.Dispose()
Sqlcmmd.Connection = Nothing
End Try
Return err
End Function
No comments:
Post a Comment