I want to call a function in an 'If' statement, I have done this before but it was different. This is how I did it before:
If Not validatePhone(txtContactNumber.Text) Then
......
End If
That is straight forward for me because I know what to put in the brackets, but I want to call a function that checks that a database:
If Not checkDatabaseExists() Then
......
End If
I do not know what parameters go into the brackets here. This is the code for the function 'checkDatabaseExists':
Public Shared Function checkDatabaseExists(ByVal server As String, ByVal database As String) As Boolean
Dim conString As String = ("Data Source=.\SQLExpress;Initial Catalog=Visitors;Integrated Security=True;MultipleActiveResultSets=True")
Dim cmdText As String = ("SELECT * FROM master.dbo.sysdatabases WHERE Name=Visitors")
Dim databaseExists As Boolean = False
Using sqlConnection As SqlConnection = New SqlConnection(conString)
sqlConnection.Open()
Using sqlCmd As SqlCommand = New SqlCommand(cmdText, sqlConnection)
Using reader As SqlDataReader = sqlCmd.ExecuteReader
databaseExists = reader.HasRows
End Using
End Using
End Using
Return databaseExists
End Function
Can anyone help me? I know it's something simple and I'll be kicking myself when I find out what it is but I haven't a clue at the moment unfortunately. All help with this matter would be greatly appreciated.
Edit:
I get the following error without having parameters in the checkDatabaseExists() part of the 'If' statement:
'Argument not specified for parameter "database" of "Public Shared Function checkDatabaseExists(ByVal server As String, ByVal database As String) As Boolean" '