The Program runs a query on a SQL Database, then it takes the gathered information and outputs it into an excel document and saves it to a specified location.
References for this Post
Database: DBase1
Server: DBaseServer\Group
User Id: ProgramUser
Password: Pword0
Problem:
I am telling the program to use a specific connection string inside the sub and it uses part of it but not all of it. It will only connect to the server if your windows login has permissions in the server to do so. In the connection string there is a general login that it is supposed to use but doesn't.
Question:
How do I tell/force the program to use the specified login? In the case that the specified login does not have the correct permissions or enough permissions to do what I am instructing it to do, does it fall back onto the windows login? Or is there some reason that it just doesn't use the specified login?
Expand|Select|Wrap|Line Numbers
- Dim connstring As String = _
- "server = DBaseServer\Group;" _
- & "integrated security = true;" _
- & "initial catalog = DBase1;" _
- & "user id = ProgramUser;" _
- & "password = Pword0"
- ' Create connection
- Dim conn As SqlConnection = New SqlConnection(connstring)
- Dim sql As String = _
- " select distinct " _
- & getSelect(dcount) _
- & " from " _
- & getFrom() _
- & " where " _
- & getWhere(dcount) _
- & " Order By FunctionID Desc, Lastname "
- ' Create Command
- Dim cmd As SqlCommand = New SqlCommand(sql, conn)
- Dim x As Integer = 1
- While rdr.Read
- For i = 0 To uiResultsSelectedListBox.Items.Count - 1
- While (Convert.ToString(uiResultsSelectedListBox.Items.Item(i)) = "Blank Column")
- i = i + 1
- End While
- oSheet.Cells(x + 1, i + 1).value = Convert.ToString(rdr(i))
- Next
- x = x + 1
- End While
- conn.Close()
Thank you for any help you have to offer me. If you need any more explanation to help or more code just let me know.