473,396 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SQL Connection and VB.NET 2005

Background:
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
  1. Dim connstring As String = _
  2.             "server = DBaseServer\Group;" _
  3.            & "integrated security = true;" _
  4.            & "initial catalog = DBase1;" _
  5.            & "user id = ProgramUser;" _
  6.            & "password = Pword0"
  7.  
  8. ' Create connection
  9.         Dim conn As SqlConnection = New SqlConnection(connstring)
  10.  
  11. Dim sql As String = _
  12.              " select distinct " _
  13.             & getSelect(dcount) _
  14.             & " from    " _
  15.             & getFrom() _
  16.             & " where   " _
  17.             & getWhere(dcount) _
  18.             & " Order By FunctionID Desc, Lastname "
  19.  
  20. ' Create Command
  21.         Dim cmd As SqlCommand = New SqlCommand(sql, conn)
  22.  
  23. Dim x As Integer = 1
  24.         While rdr.Read
  25.             For i = 0 To uiResultsSelectedListBox.Items.Count - 1
  26.                 While (Convert.ToString(uiResultsSelectedListBox.Items.Item(i)) = "Blank Column")
  27.                     i = i + 1
  28.                 End While
  29.                 oSheet.Cells(x + 1, i + 1).value = Convert.ToString(rdr(i))
  30.             Next
  31.             x = x + 1
  32.         End While
  33.         conn.Close()
  34.  
Comments:
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.
Oct 24 '07 #1
2 3454
Plater
7,872 Expert 4TB
When you use:
Expand|Select|Wrap|Line Numbers
  1. "integrated security = true;" 
  2.  
You tell it to use windows authentication and ignore the username and password combination in the connection string.



And no, if the credentials it uses can't performa a task, it will throw an exception.
Oct 24 '07 #2
Thank you very much.

I feel a little silly though. Throughout my code there are 4 instances of a connection string and somehow that single "most important" connection slipped through with a true instead of false like the rest.

I guess i can take this as a learning experience as to how to use windows and SQL authentication and that having 1 place to declare a connection string is better than 4.
Oct 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: amber | last post by:
Hello, I've just upgraded from .NET 2003 to 2005 and to SQL Server Express 2005. I've rebuilt my connection string. Before I used app.config, and now have the connection string is in the...
17
by: Danieltbt05 | last post by:
just installed SQL server 2000 and using my client , i can't locate the server. I used SQL query analyzer to search but no servers were found. Error message is as below Server : Msg17,level...
15
by: ezmiller | last post by:
Does anybody know how to use javascript to test whether or not an internet connection exists? Is this possible even?
0
by: Hongbo | last post by:
Hi, I have a test server with Windows 2003 Standard Server. SQL Server 2000 Standard Edition was installed earlier as default instance. My ASP.Net web site works fine with the connection...
16
by: crbd98 | last post by:
Hello All, Some time ago, I implemented a data access layer that included a simple connectin pool. At the time, I did it all by myself: I created N connections, each connection associated with...
3
by: Ted | last post by:
In WSAT, I get the following error when trying to set up my provider: Could not establish a connection to the database. If you have not yet created the SQL Server database, exit the Web Site...
1
by: =?Utf-8?B?TWVuYWth?= | last post by:
i have developed a web application for intranet and it is installed on the Computer name 'Server' and its already installed sql server 2005, never problem when connecting to sql server 2005 on the...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
9
by: fniles | last post by:
I am using VB.NET 2003 and SQL 2005. To use connection pooling and avoid the error "There is already an open DataReader associated with this Connection which must be closed first." , I understand...
2
by: samadams_2006 | last post by:
Hello, I have a problem that I'm hoping someone will be able to help me resolve. 1) I have a C# Web Site in which I connect to the database: "Install Microsoft SQL Server 2005 Express...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.