User Id & Password problems

G

Guest

Hello,

Currently, I'm using Visual Studio 2003, C#, Framework 1.1 and Enterprise
Library 2005 (for framework 1.1).

I've used the Enterprise Library Configuration utility to create my
connection to SQL Server, however when I run my C# program that calls a
Stored Procedure it fails. Here is what the ConnectionString block looks
like in my dataConfiguration.config file.

<connectionString name="SQL Connection String">
<parameters>
<parameter name="data source" value="SQL123" isSensitive="false"
/>
<parameter name="initial catalog" value="MyDB"
isSensitive="false" />
<parameter name="persist security info" value="False"
isSensitive="false" />
<parameter name="uid" value="userid" isSensitive="true" />
<parameter name="packet size" value="4096" isSensitive="false" />
<parameter name="pwd" value="password" isSensitive="true" />
</parameters>
</connectionString>

I noticed that when the Enterprise Library reads the
dataConfiguration.config file it looks for "uid" & "pwd", and strips it out,
so then my connection fails because it doesn't have the correct credentials.

Can anyone tell me why I am can't connect to my DB? Is there another step I
need to take in my C# program to make the connection? Here's what the code
looks like:


Database db = DatabaseFactory.CreateDatabase("SQL Server");

string sqlCommand = "autoApInput_getFile";
DBCommandWrapper dbCommandWrapper =
db.GetStoredProcCommandWrapper(sqlCommand);

// Add paramters
// Input parameters can specify the input value
dbCommandWrapper.AddInParameter("@visitor", DbType.Int32, 1);
dbCommandWrapper.AddInParameter("@po", DbType.String, "0018487402");
dbCommandWrapper.AddInParameter("@poAmount", DbType.String, "$156.25");

db.ExecuteNonQuery(dbCommandWrapper);


Thanks,
 
D

Dave Sexton

Hi SAL,

Is the error security-related?

Try setting persist security info to True.
 
G

Guest

Yes, because ConnectionStringNoCredentials() searches for uid & pwd and
removes it, then builds the connectionString with-out and I'm not sure why.

I have not been able to find anything on the internet who's using the EntLib
1 who have experienced this.
 
G

Guest

In other words,

The ConnectionStringBuilder in the Enterprise Library 1.0 builds the
connectiong string like this:

data source=sql123;initial catalog=MyDb;persist security info=true;packet
size=4096

Instead of like this:

data source=SQL123;initial catalog=MyDb;persist security info=False;user
id=youruid;;packet size=4096; password=yourpwd"

I don't know if there's a step I'm missing in my C# program, but the only
reason I'm using the dataConfiguration.config with a uid & pwd in it is
because it's an App without a UI.
 
G

Guest

It turns out, that someone changed the Initial Catalog value to include an
underscore (_) and I was unaware of it. As soon as I changed it, it worked
like a charm.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top