Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Thursday, March 22, 2012

ConnectionString nightmare

I'm having a hard time making a connection work in my ASP.Net page and would be most appreciative of any help. Here two different code snipets and the errors they generate:

ATTEMPT 1:

Dim cnWebDataUtility As SQLConnection
cnWebDataUtility = new SqlConnection("server="AVILA-4400; database=WebDataUtility; uid=AVILA-4400\ASPNET; pwd=;")
cnWebDataUtility.Open()

ERROR: System.Data.SqlClient.SqlException: Login failed for user 'AVILA-4400\ASPNET'. Reason: Not associated with a trusted SQL Server connection.

ATTEMPT 2:

Dim cnWebDataUtility As SQLConnection
cnWebDataUtility = new SqlConnection("server="AVILA-4400; Database=WebDataUtility; Integrated Security=SSPI")
cnWebDataUtility.Open()

ERROR: System.Data.SqlClient.SqlException: Login failed for user 'AVILA-4400\ASPNET'.

BACKGROUND INFO:

I recently installed SQL Server Developer Edition. During that installation it did not allow me to select anything but "Windows Login" (I am not sure of the exact wording) for authentication, I believe it was. I would expect this to mean, in terms of the connectionstring, "Integrated Security=SSPI." I have tried making this connection in Visual Studio .NET and it works, but when I copy the contents of the ConnectString property in the Properties window in VS to my ConnectionString in the code above, I get errors that it does not recognize a "provider" property, and so on.

How frustrating. If anyone can help me understand this mess, I'd be very grateful.

Thank you,

Paul.I've never seen a connection string with double-quotes around the 'server=' portion of the connection string (probably just a typo?). Nor have I ever seen the server name prepended to the 'uid'. Try:

server=AVILA-4400; database=WebDataUtility; uid=ASPNET; pwd=yourPassword;

I assume that "ASPNET" is the Database Login and you've omitted the password on purpose?

This should work.sqlsql

Tuesday, March 20, 2012

Connections not closing?

Hi, hoping someone can offer some explanations.
I've rigorously checked my java code and confirmed that every place I open a connection is done in a try {} block and the connection is closed in the follwoing finally {} block. There is one exception to this. I'm using the log4j JDBCAppender which open
s a single connection to the database and keeps that connection open.
Looking at the performance monitor, I can see that I have many, many open connections. Looking at SQLServer, though, I see that these are all sleeping.
Any thoughts on this? I did notice this page http://support.microsoft.com/default...;en-us;313220. Could that be what I'm seeing? If so, will additional writes over that connection re-use the implicitly opened connections?
Thanks for any help.
I'd have to see the code, but it hints at
a multithreading issue. I'll bet it goes away
if you *define* the connection as a method-scoped
variable, in the method(s) where it's used, just
before the try block that sets it. That way,
two simultaneous threads won't set the same variable
with two newly-obtained connections, with the last one
overwriting the first, both using and closing the second,
and the first hangs till GC'ed and maybe never closed...
Joe Weinstein at BEA
Chris Baird wrote:

> Hi, hoping someone can offer some explanations.
> I've rigorously checked my java code and confirmed that every place I open a connection is done in a try {} block and the connection is closed in the follwoing finally {} block. There is one exception to this. I'm using the log4j JDBCAppender which op
ens a single connection to the database and keeps that connection open.
> Looking at the performance monitor, I can see that I have many, many open connections. Looking at SQLServer, though, I see that these are all sleeping.
> Any thoughts on this? I did notice this page http://support.microsoft.com/default...;en-us;313220. Could that be what I'm seeing? If so, will additional writes over that connection re-use the implicitly opened connections?
> Thanks for any help.
|||Thanks, Joe.
Actually, my only connection definitions are method scoped. The only one that does not fit this is for the log4j JDBCAppender; however, only one instance of that class is created. All of my methods that use connections look like:
Connection connection = null;
try {
connection = getConnection();
// do stuff
} finally {
closeConnection(connection);
}
Where getConnection() does the normal DriverManager call and closeConnection() just ensures that the passed connection object is not null before trying to close it.
|||Ok, then
Chris Baird wrote:
> Thanks, Joe.
> Actually, my only connection definitions are method scoped. The only one that does not fit this is for the log4j JDBCAppender; however, only one instance of that class is created. All of my methods that use connections look like:
> Connection connection = null;
> try {
> connection = getConnection();
> // do stuff
> } finally {
> closeConnection(connection);
> }
> Where getConnection() does the normal DriverManager call and closeConnection() just ensures that the passed connection object is not null before trying to close it.
Ok. The code looks good then. Here's what I would do: Whenever I got a connection,
I would record or print out the spid, and whenever I closed a connection I would
again print out it's spid before closing. In fact I might query *all* the spids
before closing one, and after (via another connection). The only suspect might
be the driver itself pooling connections. Ah, but note that this driver, unless you
set selectMethod=cursor, will create cloned connections under the covers to
implement multiple concurrent statements. If you're sure to use only one statement
at a time, and close it before opening another, it might go away.
Joe Weinstein at BEA
sqlsql

Connections made by call to createStatement?

Hi:
I am using the following code to test connections made to an SQL Server 2000
database:
Statement stmt = con.createStatement ();
stmt.executeQuery ("select * from control");
stmt = con.createStatement ();
stmt.executeQuery ("select * from control");
stmt = con.createStatement ();
stmt.executeQuery ("select * from control");
con has previously been set up as a Connection object obtained via a call to
DriverManager.
When I look at the output of sp_who in SQL Query Analyzer, I see that a new
SQL Server process has been created each time that createStatement is called
(actually, not the first time; only one process exists after that call, and
that process appears after the call to DriverManager.getConnection).
I'm trying to avoid the JDBC driver make multiple connections to the SQL
Server for performance reasons; if it really is making a new connection each
time, that would obviously require some time which I don't want to waste.
It's possible I'm misinterpeting the output of Query Analyzer, and that
multiple database processes can be listed that are all using the same actual
connection (this seems possible, as the output of stmt.getConnection()
remains the same each time a stmt object is allocated in the code above).
Can anyone explain this behavior?
Thanks,
Ryan
Add the property 'selectMethod=cursor' to your connection-getting and this
odd behavior of the driver will go away.
Joe
Ryan McFall wrote:

> Hi:
> I am using the following code to test connections made to an SQL Server 2000
> database:
> Statement stmt = con.createStatement ();
> stmt.executeQuery ("select * from control");
> stmt = con.createStatement ();
> stmt.executeQuery ("select * from control");
> stmt = con.createStatement ();
> stmt.executeQuery ("select * from control");
> con has previously been set up as a Connection object obtained via a call to
> DriverManager.
> When I look at the output of sp_who in SQL Query Analyzer, I see that a new
> SQL Server process has been created each time that createStatement is called
> (actually, not the first time; only one process exists after that call, and
> that process appears after the call to DriverManager.getConnection).
> I'm trying to avoid the JDBC driver make multiple connections to the SQL
> Server for performance reasons; if it really is making a new connection each
> time, that would obviously require some time which I don't want to waste.
> It's possible I'm misinterpeting the output of Query Analyzer, and that
> multiple database processes can be listed that are all using the same actual
> connection (this seems possible, as the output of stmt.getConnection()
> remains the same each time a stmt object is allocated in the code above).
> Can anyone explain this behavior?
> Thanks,
> Ryan
>

Sunday, March 11, 2012

Connection.close returns a 91 error code...

I have the next code in my proyect:

If CurrentProject.IsConnected Then
MsgBox "Base ya Conectada.Procedemos a cerrarla primero", vbOKOnly
If SQLConexion.State = adStateOpen Then SQLConexion.Close
SQLConexion.Close
End If
SQLConexion.Open SQLSentencia
AbreConexionSQLSERVER = 0

If I detect that the connection is opened while I am initializazing varriables, I want to close always the connection and then begins my aplicattion always opening the connection, but it always returns a error 91..

suggestions?

hi,

the message text instead of the error code would better help, but your code actually closes the conntection 2 times in the IF block, and this usually results in an axception to be raised..

regards

Connection works for a while then gets this : [DBMSLPCN]SQL Server does not exist or acces

Situation:
We have some custom code running on microsoft great plains **under
terminal services** on a windows 2003 machine.
We have a program (running under great plains) that will run for about
5 minutes, then give the error
[Microsoft][ODBC SQL Server Driver][DBMSLPNCN]SQL Server does not exist
or access denied.
I've tried disabling the shared memory protocol in the client network
utility. That didn't have any effect...even though the error points to
the shared memory protocol.
Now, I've got aql running on a non-standard port or 1150. If I change
this back to the default 1433, the program works fine.
Any ideas why?
Steven Vallarian
Hi
You may look at netstat to see what is connected to the ports of use PortQry
to see if you can connect:
http://support.microsoft.com/default...b;en-us;310099
It may be that you just have general network problems such as a faulty
switch.
John
"svallarian" <svallarian@.hotmail.com> wrote in message
news:1109778822.752029.318690@.l41g2000cwc.googlegr oups.com...
> Situation:
> We have some custom code running on microsoft great plains **under
> terminal services** on a windows 2003 machine.
> We have a program (running under great plains) that will run for about
> 5 minutes, then give the error
> [Microsoft][ODBC SQL Server Driver][DBMSLPNCN]SQL Server does not exist
> or access denied.
> I've tried disabling the shared memory protocol in the client network
> utility. That didn't have any effect...even though the error points to
> the shared memory protocol.
> Now, I've got aql running on a non-standard port or 1150. If I change
> this back to the default 1433, the program works fine.
> Any ideas why?
>
> Steven Vallarian
>

Connection works for a while then gets this : [DBMSLPCN]SQL Server does not exist or a

Situation:
We have some custom code running on microsoft great plains **under
terminal services** on a windows 2003 machine.
We have a program (running under great plains) that will run for about
5 minutes, then give the error
[Microsoft][ODBC SQL Server Driver][DBMSLPNCN]SQL Server does no
t exist
or access denied.
I've tried disabling the shared memory protocol in the client network
utility. That didn't have any effect...even though the error points to
the shared memory protocol.
Now, I've got aql running on a non-standard port or 1150. If I change
this back to the default 1433, the program works fine.
Any ideas why?
Steven VallarianHi
You may look at netstat to see what is connected to the ports of use PortQry
to see if you can connect:
http://support.microsoft.com/defaul...kb;en-us;310099
It may be that you just have general network problems such as a faulty
switch.
John
"svallarian" <svallarian@.hotmail.com> wrote in message
news:1109778822.752029.318690@.l41g2000cwc.googlegroups.com...
> Situation:
> We have some custom code running on microsoft great plains **under
> terminal services** on a windows 2003 machine.
> We have a program (running under great plains) that will run for about
> 5 minutes, then give the error
> [Microsoft][ODBC SQL Server Driver][DBMSLPNCN]SQL Server does
not exist
> or access denied.
> I've tried disabling the shared memory protocol in the client network
> utility. That didn't have any effect...even though the error points to
> the shared memory protocol.
> Now, I've got aql running on a non-standard port or 1150. If I change
> this back to the default 1433, the program works fine.
> Any ideas why?
>
> Steven Vallarian
>

Connection Using Gobal ASP

I am having trouble connecting to my SQL Server. I am using InterDev and mod
ifing the gobal.asp.
This is the code I am using
application("DBConn")="Provider=SQLOLEDB;User ID=sa;Initial Catalog=northwin
d;Data Source=192.168.20.17;PASSWORD=;"
Is this correct? If not what should I modify?What errors do you receive? That might help us provide an answer.
First off, I would not use the 'sa' account for a web app.
Create a separate SQL Server login (with limited permissions) and use =
that.
Secondly, you should probably have a password on the account that you =
are using. I am guessing that you may have left that piece out of your =
post because you did not want to tell us your sa password.
Thirdly, do you want the initial database to be northwind?
--=20
Keith
"Jack Temple" <anonymous@.discussions.microsoft.com> wrote in message =
news:9A428A01-1348-4F81-B46B-511CC98ACF0B@.microsoft.com...
> I am having trouble connecting to my SQL Server. I am using InterDev =
and modifing the gobal.asp.
>=20
> This is the code I am using=20
>=20
> application("DBConn")=3D"Provider=3DSQLOLEDB;User ID=3Dsa;Initial =
Catalog=3Dnorthwind;Data Source=3D192.168.20.17;PASSWORD=3D;"
>=20
> Is this correct? If not what should I modify?
>=20
>

Thursday, March 8, 2012

connection to sql server

Hi,

Im using asp code. how to i connect to sql server. could anyone provide me the coding to connect. and how to setup the connection.Hi
You can find the resources Here or Here|||hi,

im using this coding for the connection to sql server

<%
Set demoConn = Server.CreateObject("ADODB.Connection")
demoPath="DRIVER={SQLServer};" & _
"SERVER=servername;UID=username;" & _
"PWD=password;DATABASE=database"
demoConn.open demoPath
%>

but still couldnt, is there any setup that i have to do. something like odbc setup or any else setup. thanks

Wednesday, March 7, 2012

connection to another server

Hello there
I'm working with query anlyser.
Is there a way with code to transfare to another server?
Roy,
Transfer what? Can you please explain in a little more detail what you want
to accomplish?
Andrew J. Kelly SQL MVP
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:%23akEH2GCGHA.1312@.TK2MSFTNGP09.phx.gbl...
> Hello there
> I'm working with query anlyser.
> Is there a way with code to transfare to another server?
>
|||Yes Andrew
It begun from another issue i've asked on DTS aboud the log file.
I dound the property you said about TABLOCK by using sp_tableoption and it
worked fine: the log file hasen't grow in a bit. Thanks
I could run the store procedure only on the destination object by connect it
by query anlyser
I'm trying to build store procedure that will do all the options. In order
to do that i must run sp_tableoption on the destination tables on the
diffrent server. and the store procedure must start from the source server
How can i do that?
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:elQeVHJCGHA.4040@.TK2MSFTNGP12.phx.gbl...
> Roy,
> Transfer what? Can you please explain in a little more detail what you
want
> to accomplish?
> --
> Andrew J. Kelly SQL MVP
>
> "Roy Goldhammer" <roy@.hotmail.com> wrote in message
> news:%23akEH2GCGHA.1312@.TK2MSFTNGP09.phx.gbl...
>
|||It doesn't matter where you run QA from as the code itself is always run on
the server itself, not the client. So I am still confused as to what you
want to do that you can't already. Is it a permissions issue?
Andrew J. Kelly SQL MVP
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:%23Y2h8LJCGHA.3936@.TK2MSFTNGP12.phx.gbl...
> Yes Andrew
> It begun from another issue i've asked on DTS aboud the log file.
> I dound the property you said about TABLOCK by using sp_tableoption and it
> worked fine: the log file hasen't grow in a bit. Thanks
> I could run the store procedure only on the destination object by connect
> it
> by query anlyser
> I'm trying to build store procedure that will do all the options. In order
> to do that i must run sp_tableoption on the destination tables on the
> diffrent server. and the store procedure must start from the source server
> How can i do that?
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:elQeVHJCGHA.4040@.TK2MSFTNGP12.phx.gbl...
> want
>

connection to another server

Hello there
I'm working with query anlyser.
Is there a way with code to transfare to another server?Roy,
Transfer what? Can you please explain in a little more detail what you want
to accomplish?
Andrew J. Kelly SQL MVP
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:%23akEH2GCGHA.1312@.TK2MSFTNGP09.phx.gbl...
> Hello there
> I'm working with query anlyser.
> Is there a way with code to transfare to another server?
>|||Yes Andrew
It begun from another issue i've asked on DTS aboud the log file.
I dound the property you said about TABLOCK by using sp_tableoption and it
worked fine: the log file hasen't grow in a bit. Thanks
I could run the store procedure only on the destination object by connect it
by query anlyser
I'm trying to build store procedure that will do all the options. In order
to do that i must run sp_tableoption on the destination tables on the
diffrent server. and the store procedure must start from the source server
How can i do that?
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:elQeVHJCGHA.4040@.TK2MSFTNGP12.phx.gbl...
> Roy,
> Transfer what? Can you please explain in a little more detail what you
want
> to accomplish?
> --
> Andrew J. Kelly SQL MVP
>
> "Roy Goldhammer" <roy@.hotmail.com> wrote in message
> news:%23akEH2GCGHA.1312@.TK2MSFTNGP09.phx.gbl...
>|||It doesn't matter where you run QA from as the code itself is always run on
the server itself, not the client. So I am still confused as to what you
want to do that you can't already. Is it a permissions issue?
Andrew J. Kelly SQL MVP
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:%23Y2h8LJCGHA.3936@.TK2MSFTNGP12.phx.gbl...
> Yes Andrew
> It begun from another issue i've asked on DTS aboud the log file.
> I dound the property you said about TABLOCK by using sp_tableoption and it
> worked fine: the log file hasen't grow in a bit. Thanks
> I could run the store procedure only on the destination object by connect
> it
> by query anlyser
> I'm trying to build store procedure that will do all the options. In order
> to do that i must run sp_tableoption on the destination tables on the
> diffrent server. and the store procedure must start from the source server
> How can i do that?
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:elQeVHJCGHA.4040@.TK2MSFTNGP12.phx.gbl...
> want
>

Saturday, February 25, 2012

Connection string with sa password

My application designed with VB6.0 is connected to MS SQL Server 7.0.
Server has password for sa login. The VB code for connection is next:
Dim Conn As ADODB.Connection
Set Conn = New ADODB.Connection
Conn.ConnectionTimeout = 30
Conn.ConnectionString = Provider=SQLOLEDB.1;Persist Security
Info=False;User ID=sa;Initial Catalog=master;Data
Source=server;Password=mypassword;
Conn.Open
Connection performs successfully but after that Conn.ConnectionStrring
value has changed and equals
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial
Catalog=master;Data Source=retiv;Use Procedure for Prepare=1;Auto
Translate=True;Packet Size=4096;Workstation ID=USER;Use Encryption for
Data=False;Tag with column collation when possible=False
There is no any information about sa password which is not blank.
Connection object Conn is a global object in my application which is
used after, so I get a error
Login failed for user sa
How can I save my sa password in connection string?First of all, you shouldn't be using 'sa' to connect to SQL Server, from
your applications. This is a security threat, as 'sa' happens to be a
powerful login.
Then, you should be either using a DSN, or store your connection string
somewhere (Global.asa may be?), so that it is there at a specific location,
and that it never changes.
--
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"Vadim Bulat" <bulat@.asuxxivek.spb.ru> wrote in message
news:7e1d1f98.0407150731.78249213@.posting.google.com...
> My application designed with VB6.0 is connected to MS SQL Server 7.0.
> Server has password for sa login. The VB code for connection is next:
> Dim Conn As ADODB.Connection
> Set Conn = New ADODB.Connection
> Conn.ConnectionTimeout = 30
> Conn.ConnectionString = Provider=SQLOLEDB.1;Persist Security
> Info=False;User ID=sa;Initial Catalog=master;Data
> Source=server;Password=mypassword;
> Conn.Open
> Connection performs successfully but after that Conn.ConnectionStrring
> value has changed and equals
> Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial
> Catalog=master;Data Source=retiv;Use Procedure for Prepare=1;Auto
> Translate=True;Packet Size=4096;Workstation ID=USER;Use Encryption for
> Data=False;Tag with column collation when possible=False
> There is no any information about sa password which is not blank.
> Connection object Conn is a global object in my application which is
> used after, so I get a error
> Login failed for user sa
> How can I save my sa password in connection string?

Connection string with sa password

My application designed with VB6.0 is connected to MS SQL Server 7.0.
Server has password for sa login. The VB code for connection is next:
Dim Conn As ADODB.Connection
Set Conn = New ADODB.Connection
Conn.ConnectionTimeout = 30
Conn.ConnectionString = Provider=SQLOLEDB.1;Persist Security
Info=False;User ID=sa;Initial Catalog=master;Data
Source=server;Password=mypassword;
Conn.Open
Connection performs successfully but after that Conn.ConnectionStrring
value has changed and equals
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial
Catalog=master;Data Source=retiv;Use Procedure for Prepare=1;Auto
Translate=True;Packet Size=4096;Workstation ID=USER;Use Encryption for
Data=False;Tag with column collation when possible=False
There is no any information about sa password which is not blank.
Connection object Conn is a global object in my application which is
used after, so I get a error
Login failed for user sa
How can I save my sa password in connection string?
First of all, you shouldn't be using 'sa' to connect to SQL Server, from
your applications. This is a security threat, as 'sa' happens to be a
powerful login.
Then, you should be either using a DSN, or store your connection string
somewhere (Global.asa may be?), so that it is there at a specific location,
and that it never changes.
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"Vadim Bulat" <bulat@.asuxxivek.spb.ru> wrote in message
news:7e1d1f98.0407150731.78249213@.posting.google.c om...
> My application designed with VB6.0 is connected to MS SQL Server 7.0.
> Server has password for sa login. The VB code for connection is next:
> Dim Conn As ADODB.Connection
> Set Conn = New ADODB.Connection
> Conn.ConnectionTimeout = 30
> Conn.ConnectionString = Provider=SQLOLEDB.1;Persist Security
> Info=False;User ID=sa;Initial Catalog=master;Data
> Source=server;Password=mypassword;
> Conn.Open
> Connection performs successfully but after that Conn.ConnectionStrring
> value has changed and equals
> Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial
> Catalog=master;Data Source=retiv;Use Procedure for Prepare=1;Auto
> Translate=True;Packet Size=4096;Workstation ID=USER;Use Encryption for
> Data=False;Tag with column collation when possible=False
> There is no any information about sa password which is not blank.
> Connection object Conn is a global object in my application which is
> used after, so I get a error
> Login failed for user sa
> How can I save my sa password in connection string?

Friday, February 24, 2012

Connection string Problem

Hi!

I have a very silly problem here.

i am setting some variables here from c# code.

Everything works fine except for Conn string. I understand statements that works fine in SQL does not act same in C# because of string literals.

I need an extra qoute \"" ......."/" that would execute in C#

\""Data Source=SE413695\AASQL2005;Initial Catalog=TestDB;Integrated Security=SSPI;"\"

where as in c#

setting variable value as :

string scriptTaskConnectST = @."Data Source=SE413695\AASQL2005;Initial Catalog=TestDB;Integrated Security=SSPI;";

executing this through c# code

jobCommand = new SqlCommand("xp_cmdshell 'dtexec /f \"" + path + "\" /Set \\package.Variables[User::ArchivePackageName].Properties[Value];\"" + name + "\" /Set \\package.Variables[User::ScriptTaskConnectST].Properties[Value];\"" + scriptTaskConnectST + "\"

When i check i resulting vaue i get this for scriptTaskConnectST as

/"......\"

\"Data Source=SE413695\AASQL2005;Initial Catalog=TestDB;Integrated Security=SSPI;\"

how should i format it to get \""......"\"

Thanks,

Jasm

if i'm not mistaken, you've already asked this question in a previous incarnation. if true, i believe that i've already suggested that you use sql server agent stored procedures to run your package. you can execute any stored procedure from c# provided that your code has the proper permissions.

does my suggestion not work for you? if so, please tell me why that is.

|||

I need to execute the packages through C# UI. Executing Throught the Agent is a secnd case now. But i found a work around method to set the connection string in my main package and set the value into the varaible which is used by all the pther sub packages. and it is working now.

I am already executing Stored proceedure through c# now for other implementations.

Thanks for your Suggestion.

Once i finish working through the UI i will try to execute throught the agent.

Jas

Connection String in ASP.NEt

Hi

I'm using VB.NET in ASP.NET .

Windows 2000

Visual Studio 2005

and SQLServer 2005.

I'm new to VS 2005

I'm using the following code for connection

<

addkey="dsnstring"value="persist Security info=False; User ID=; password=;Initial Catalog=TransMate1; Data Source=Localhost trusted_connection=yes" />

it is giving the error as 'Cann't do the connection since user id cann't be null

It is not exact words of the error message.

following code is working fine with the SQL Server 2003 but not with SQL Server 2005.

<add key="dsnstring" value="persist Security info=False; User ID=sa; password=dreams;Initial Catalog=TransMate; Data Source=Localhost" />

Kindly help me

Thanks in advance

Regards.

If you use Trusted_Connection=yes that is, Windows Authentication, do not have userid or password in the connection string since they are dealed by the Windows authentication. You don't provide them in that case.

<add key="dsnstring" value="Initial Catalog=TransMate1; Data Source=Localhost;trusted_connection=yes" />

Sunday, February 19, 2012

Connection string for PDA

Hello,

I am using VS 2005 and developing PDA device application to run on SQL CE. The PDA has Windows CE 5.0 OS.

Now I am using the following code for connection to database: I got this code from some website on Internet but do not remember which one:

Try
Dim FullAppName As String = [Assembly].GetCallingAssembly().GetName.CodeBase
Dim FullAppPath As String = Path.GetDirectoryName(FullAppName)
MessageBox.Show(FullAppPath)

Dim FullFileName As String = Path.Combine(FullAppPath, "Test123.sdf")
Dim cn As New SqlCeConnection(String.Format("Data Source={0}", FullFileName))
MessageBox.Show(FullFileName)
cn.Open()
MessageBox.Show("Connection Success")

Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Here the problem is that
1. FullAppPath returns \Windows. But the database is in application folder i.e. \Program Files\DeviceSampleApp. Then why does it return \Windows.

2. So I copied the test123.sdf file in \Windows folder. But cn.Open goes to catch block. This means there is some error but surprisingly ex.ToString displays blank messagebox. What could be the issue?


3. I also changed the connection string as:
Dim cn As New SqlCeConnection("Data Source = \Program Files\DeviceSampleApp\Test123.sdf") and the Test123.sdf correctly gets deployed to this folder \Program Files\DeviceSampleApp\ which also has the EXE. Still it gives error that it cannot find the database Test123.sdf in the path \Program Files\DeviceSampleApp\ but I checked and it is there. What could be the issue?

Regards,
MI

For proper SQL CE error handling, see http://msdn2.microsoft.com/en-us/library/ms174079.aspx

For how to determine "App.Path" in .NET CF, see this: http://msdn2.microsoft.com/en-us/library/aa457089.aspx

|||

GetCallingAssembly() would work if this code is in the DLL which is called from your EXE. If this code is in the EXE itself use GetExecutingAssemly() instead.

Tuesday, February 14, 2012

connection string

hi, i was just wondering what's wrong with my code. i have class library to handle all the classes of my asp.net project. when im compiling a class, i am getting an error "Error 1 The name 'ConfigurationManager' does not exist in the current context " . i have this code for that error message:

string connStr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
im not sure about this because im new in asp.net. am i missing a reference here?if yes, what namespace should i include? by the way, i tested this directly in my asp.net age and it is working fine. when i use visual c#.net, that's where the error prompts me, and i cant build that class library.

Make sure this is referenced in the cs file:

using System.Configuration;

|||

Add this at the top of your pageusing System.Configuration;

connection sql server problems

What is the problems of my code to connect sql database below : thx!
Code:
Dim objConn As New OleDbConnection()
objConn.ConnectionString = "Data Source=localhost;IntegratedSecurity=SSPI;user id=sa; password=sa;Initial Catalog=rental"

objConn.Open()
Error :

An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.ArgumentException: An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.
Source Error:
Line 7: Line 8: Dim objConn As New OleDbConnection()Line 9: objConn.ConnectionString = "Data Source=localhost;IntegratedSecurity=SSPI;user id=sa; password=sa;Initial Catalog=rental"Line 10: Line 11: objConn.Open()
Your connection string is appropriate for a SqlConnection object. If you want to use an OledbConnection (which is slower), you'll have to specify Provider=sqloledb
Marcie

Connection security problems with a 3 tier application

Please bear with me as you read this description. I am trying to finish up
and productize some code that I inherited from a
contract programmer that allegedly knew what he was doing. I know that I do
n't know what I am doing.
I have an application that is written in C# for .net. It has a client porti
on, a server portion and a database back end. The
client connects to remote objects that are hosted in IIS on a server. These
objects connect the database on a 3rd system via
SQLDMO in .Net
Both the server and the SQL server systems are Windows 2003 systems.
The database is set for NT security only.
The server system is trusted for delegation. It also does impersonation.
We have a Domain Local security group (Win 2K style mixed mode Active Direct
ory) that contains users from both the AD group and a
NT 4 domain that has 2 way trust to/from the AD group.
I can access the databases on the SQL server from the client, but I am the o
nly person that can.
If someone in the NT 4 domain attempts to access, we get an error telling th
at NULL is not associated with the group.
.... Login failed for user "(null)". Reason: Not associated with secure S
QL Server connection.
If someone in the AD domain attempts to access, we get an error telling us t
hat login failed.
.... Login failed for user "domain\userid". The actual domain and userid
is listed.
I don't have any idea where this has gone wrong.
Any suggestions will be appreciated.
Thanks
---
Roy Chastain
KMSystems, Inc.Hi Roy:
The problem is not very clear.
I think we should first ping each other by IP to see if it work righ.
Then we should try to telnet each other by 1433 port.
But I guess the problem is caused by the domain or workgroup problem.
Best Wishes
Wei Ci Zhou|||You are right the problem is not very clear, because I don't know enough to
explain it correctly, however, there are some things
in my post that I though were more obvious then your response indicated.
There is connection.
1) - I can access the database
2) - The people that can not access the database are getting a response from
SQL. (Therefore connectivity)
Yes, it is a security issue, but I have no idea about how to resolve a secur
ity issue with SQL.
The database is supposed to be created with the domain group that we all bel
ong to being the owner of the database. I have not
been able to find that code in our application. I know it is there somewher
e, because the application does create the database.
Perhaps someone could tell me what to look for to find the database creation
and owner setup.
Thanks
On Fri, 26 Mar 2004 13:41:41 +0800, "Wei Ci Zhou" <weicizhou@.hotmail.com.dis
scuss> wrote:

>Hi Roy:
> The problem is not very clear.
> I think we should first ping each other by IP to see if it work righ.
> Then we should try to telnet each other by 1433 port.
> But I guess the problem is caused by the domain or workgroup problem.
>Best Wishes
>Wei Ci Zhou
>
---
Roy Chastain
KMSystems, Inc.|||Hi Roy,
As for the connectivity problem of SQL Server, there is some general steps
for us for testing.
1) ping Server_IP
2) telnet Server_IP 1433
Note that the Port 1433 is default por number fro SQL Server, You can check
the actual port number the SQL Server is using by Server Network Utility.
You can get it by check the properties of TCP/IP ( which should be enabled
protocol).
If now there is no problem of it. Then SQL Server is running properly and
you could use the Query Analyzer and ospl tools to connect from where you
need to connect the database with related credential informations. You
could also use the SQL Server Profiler to catch the connection information
from the outside. You could monitor the Audit: Login, Audit:Logout;
Sessions: ExistingConnections.
If no problem of it. Then the SQL Server is with the right configuration
for connectivity. It might be a IIS configuration problem, so, you could
ask for some information in the IIS newsgroup and our engineer there will
provide more
information on this issue.
http://msdn.microsoft.com/newsgroup...microsoft.publi
c.inetserver.iis
Hope this helps.
Best regards
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.|||Could you be so kind as to tell me how to use the SQL Server Profiler to mon
itor as you suggest.
On Mon, 29 Mar 2004 03:51:27 GMT, v-baiwei@.online.microsoft.com (Baisong Wei
[MSFT]) wrote:

>Hi Roy,
>
>As for the connectivity problem of SQL Server, there is some general steps
>for us for testing.
>1) ping Server_IP
>2) telnet Server_IP 1433
>Note that the Port 1433 is default por number fro SQL Server, You can check
> the actual port number the SQL Server is using by Server Network Utility.
>You can get it by check the properties of TCP/IP ( which should be enabled
>protocol).
>If now there is no problem of it. Then SQL Server is running properly and
>you could use the Query Analyzer and ospl tools to connect from where you
>need to connect the database with related credential informations. You
>could also use the SQL Server Profiler to catch the connection information
>from the outside. You could monitor the Audit: Login, Audit:Logout;
>Sessions: ExistingConnections.
>If no problem of it. Then the SQL Server is with the right configuration
>for connectivity. It might be a IIS configuration problem, so, you could
>ask for some information in the IIS newsgroup and our engineer there will
>provide more
>information on this issue.
>http://msdn.microsoft.com/newsgroup...ft.com/security
>This posting is provided "as is" with no warranties and confers no rights.
>Please reply to newsgroups only. Thanks.
---
Roy Chastain
KMSystems, Inc.|||I have been doing some network snooping. I have code that identifies all SQ
L servers on the network. It does a broadcast on UDP
1434 and it get responses from several servers including the one in question
.
I have client code that will connect to the server in question and that code
will display the list of databases on the server.
Somehow the code in the client knows to use port 1175. This works. The cli
ent can query the database and that query is submitted
on port 1175 and it works.
I installed the SQL Web Administration tool today. Needless to say it does
not connect to the server in question. It will
connect to at least one other server on my network.
On Mon, 29 Mar 2004 03:51:27 GMT, v-baiwei@.online.microsoft.com (Baisong Wei
[MSFT]) wrote:

>Hi Roy,
>
>As for the connectivity problem of SQL Server, there is some general steps
>for us for testing.
>1) ping Server_IP
>2) telnet Server_IP 1433
>Note that the Port 1433 is default por number fro SQL Server, You can check
> the actual port number the SQL Server is using by Server Network Utility.
>You can get it by check the properties of TCP/IP ( which should be enabled
>protocol).
>If now there is no problem of it. Then SQL Server is running properly and
>you could use the Query Analyzer and ospl tools to connect from where you
>need to connect the database with related credential informations. You
>could also use the SQL Server Profiler to catch the connection information
>from the outside. You could monitor the Audit: Login, Audit:Logout;
>Sessions: ExistingConnections.
>If no problem of it. Then the SQL Server is with the right configuration
>for connectivity. It might be a IIS configuration problem, so, you could
>ask for some information in the IIS newsgroup and our engineer there will
>provide more
>information on this issue.
>http://msdn.microsoft.com/newsgroup...ft.com/security
>This posting is provided "as is" with no warranties and confers no rights.
>Please reply to newsgroups only. Thanks.
---
Roy Chastain
KMSystems, Inc.|||Hi Roy,
As testing the connection to SQL Server, as you application will use the
specific credential information to connect to the SQL Server (windows
authentication or SQL Server authentication), you could use profiler to
catch this login information in Profiler:
When new a trace in the profiler, you could trace Audit Login and Audit
Login Failed in the Security Audit Event, and you will get all the
connection information of it.
You could refer to this article:
How to troubleshoot connectivity issues in SQL Server 2000
http://support.microsoft.com/?id=827422
Monitoring with SQL Profiler
http://msdn.microsoft.com/library/d...-us/adminsql/ad
_mon_perf_86ib.asp
Hope this helps
Best regards
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.|||Hi Roy,
I am reviewing your post and I provide you some links for connectivity to
SQL Server. I wonder if it is helpful or if you still have questions about
it. For this question, the first step we do is check that the credentials
used to connect the SQL server is valid. ( information are valid as SQL
logins). If yes, then the problem might be related to IIS configuration or
some Windows security policies. You could ask for help from:
http://msdn.microsoft.com/newsgroup...microsoft.publi
c.inetserver.iis
Hope this helps
Best regards
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.|||I gave up and opened a support incident yesterday. After 4 hrs on the phone
we thought it was resolved, but we were wrong.
On Thu, 01 Apr 2004 01:28:07 GMT, v-baiwei@.online.microsoft.com (Baisong Wei
[MSFT]) wrote:

>Hi Roy,
>I am reviewing your post and I provide you some links for connectivity to
>SQL Server. I wonder if it is helpful or if you still have questions about
>it. For this question, the first step we do is check that the credentials
>used to connect the SQL server is valid. ( information are valid as SQL
>logins). If yes, then the problem might be related to IIS configuration or
>some Windows security policies. You could ask for help from:
>http://msdn.microsoft.com/newsgroup...ft.com/security
>This posting is provided "as is" with no warranties and confers no rights.
>Please reply to newsgroups only. Thanks.
---
Roy Chastain
KMSystems, Inc.

Connection security problems with a 3 tier application

Please bear with me as you read this description. I am trying to finish up and productize some code that I inherited from a
contract programmer that allegedly knew what he was doing. I know that I don't know what I am doing.
I have an application that is written in C# for .net. It has a client portion, a server portion and a database back end. The
client connects to remote objects that are hosted in IIS on a server. These objects connect the database on a 3rd system via
SQLDMO in .Net
Both the server and the SQL server systems are Windows 2003 systems.
The database is set for NT security only.
The server system is trusted for delegation. It also does impersonation.
We have a Domain Local security group (Win 2K style mixed mode Active Directory) that contains users from both the AD group and a
NT 4 domain that has 2 way trust to/from the AD group.
I can access the databases on the SQL server from the client, but I am the only person that can.
If someone in the NT 4 domain attempts to access, we get an error telling that NULL is not associated with the group.
..... Login failed for user "(null)". Reason: Not associated with secure SQL Server connection.
If someone in the AD domain attempts to access, we get an error telling us that login failed.
..... Login failed for user "domain\userid". The actual domain and userid is listed.
I don't have any idea where this has gone wrong.
Any suggestions will be appreciated.
Thanks
Roy Chastain
KMSystems, Inc.
Hi Roy:
The problem is not very clear.
I think we should first ping each other by IP to see if it work righ.
Then we should try to telnet each other by 1433 port.
But I guess the problem is caused by the domain or workgroup problem.
Best Wishes
Wei Ci Zhou
|||You are right the problem is not very clear, because I don't know enough to explain it correctly, however, there are some things
in my post that I though were more obvious then your response indicated.
There is connection.
1) - I can access the database
2) - The people that can not access the database are getting a response from SQL. (Therefore connectivity)
Yes, it is a security issue, but I have no idea about how to resolve a security issue with SQL.
The database is supposed to be created with the domain group that we all belong to being the owner of the database. I have not
been able to find that code in our application. I know it is there somewhere, because the application does create the database.
Perhaps someone could tell me what to look for to find the database creation and owner setup.
Thanks
On Fri, 26 Mar 2004 13:41:41 +0800, "Wei Ci Zhou" <weicizhou@.hotmail.com.disscuss> wrote:

>Hi Roy:
> The problem is not very clear.
> I think we should first ping each other by IP to see if it work righ.
> Then we should try to telnet each other by 1433 port.
> But I guess the problem is caused by the domain or workgroup problem.
>Best Wishes
>Wei Ci Zhou
>
Roy Chastain
KMSystems, Inc.
|||Hi Roy,
As for the connectivity problem of SQL Server, there is some general steps
for us for testing.
1) ping Server_IP
2) telnet Server_IP 1433
Note that the Port 1433 is default por number fro SQL Server, You can check
the actual port number the SQL Server is using by Server Network Utility.
You can get it by check the properties of TCP/IP ( which should be enabled
protocol).
If now there is no problem of it. Then SQL Server is running properly and
you could use the Query Analyzer and ospl tools to connect from where you
need to connect the database with related credential informations. You
could also use the SQL Server Profiler to catch the connection information
from the outside. You could monitor the Audit: Login, Audit:Logout;
Sessions: ExistingConnections.
If no problem of it. Then the SQL Server is with the right configuration
for connectivity. It might be a IIS configuration problem, so, you could
ask for some information in the IIS newsgroup and our engineer there will
provide more
information on this issue.
http://msdn.microsoft.com/newsgroups...icrosoft.publi
c.inetserver.iis
Hope this helps.
Best regards
Baisong Wei
Microsoft Online Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.
|||Could you be so kind as to tell me how to use the SQL Server Profiler to monitor as you suggest.
On Mon, 29 Mar 2004 03:51:27 GMT, v-baiwei@.online.microsoft.com (Baisong Wei[MSFT]) wrote:

>Hi Roy,
>
>As for the connectivity problem of SQL Server, there is some general steps
>for us for testing.
>1) ping Server_IP
>2) telnet Server_IP 1433
>Note that the Port 1433 is default por number fro SQL Server, You can check
> the actual port number the SQL Server is using by Server Network Utility.
>You can get it by check the properties of TCP/IP ( which should be enabled
>protocol).
>If now there is no problem of it. Then SQL Server is running properly and
>you could use the Query Analyzer and ospl tools to connect from where you
>need to connect the database with related credential informations. You
>could also use the SQL Server Profiler to catch the connection information
>from the outside. You could monitor the Audit: Login, Audit:Logout;
>Sessions: ExistingConnections.
>If no problem of it. Then the SQL Server is with the right configuration
>for connectivity. It might be a IIS configuration problem, so, you could
>ask for some information in the IIS newsgroup and our engineer there will
>provide more
>information on this issue.
>http://msdn.microsoft.com/newsgroups...icrosoft.publi
>c.inetserver.iis
>Hope this helps.
>Best regards
>Baisong Wei
>Microsoft Online Support
>----
>Get Secure! - www.microsoft.com/security
>This posting is provided "as is" with no warranties and confers no rights.
>Please reply to newsgroups only. Thanks.
Roy Chastain
KMSystems, Inc.
|||I have been doing some network snooping. I have code that identifies all SQL servers on the network. It does a broadcast on UDP
1434 and it get responses from several servers including the one in question.
I have client code that will connect to the server in question and that code will display the list of databases on the server.
Somehow the code in the client knows to use port 1175. This works. The client can query the database and that query is submitted
on port 1175 and it works.
I installed the SQL Web Administration tool today. Needless to say it does not connect to the server in question. It will
connect to at least one other server on my network.
On Mon, 29 Mar 2004 03:51:27 GMT, v-baiwei@.online.microsoft.com (Baisong Wei[MSFT]) wrote:

>Hi Roy,
>
>As for the connectivity problem of SQL Server, there is some general steps
>for us for testing.
>1) ping Server_IP
>2) telnet Server_IP 1433
>Note that the Port 1433 is default por number fro SQL Server, You can check
> the actual port number the SQL Server is using by Server Network Utility.
>You can get it by check the properties of TCP/IP ( which should be enabled
>protocol).
>If now there is no problem of it. Then SQL Server is running properly and
>you could use the Query Analyzer and ospl tools to connect from where you
>need to connect the database with related credential informations. You
>could also use the SQL Server Profiler to catch the connection information
>from the outside. You could monitor the Audit: Login, Audit:Logout;
>Sessions: ExistingConnections.
>If no problem of it. Then the SQL Server is with the right configuration
>for connectivity. It might be a IIS configuration problem, so, you could
>ask for some information in the IIS newsgroup and our engineer there will
>provide more
>information on this issue.
>http://msdn.microsoft.com/newsgroups...icrosoft.publi
>c.inetserver.iis
>Hope this helps.
>Best regards
>Baisong Wei
>Microsoft Online Support
>----
>Get Secure! - www.microsoft.com/security
>This posting is provided "as is" with no warranties and confers no rights.
>Please reply to newsgroups only. Thanks.
Roy Chastain
KMSystems, Inc.
|||Hi Roy,
As testing the connection to SQL Server, as you application will use the
specific credential information to connect to the SQL Server (windows
authentication or SQL Server authentication), you could use profiler to
catch this login information in Profiler:
When new a trace in the profiler, you could trace Audit Login and Audit
Login Failed in the Security Audit Event, and you will get all the
connection information of it.
You could refer to this article:
How to troubleshoot connectivity issues in SQL Server 2000
http://support.microsoft.com/?id=827422
Monitoring with SQL Profiler
http://msdn.microsoft.com/library/de...us/adminsql/ad
_mon_perf_86ib.asp
Hope this helps
Best regards
Baisong Wei
Microsoft Online Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.
|||Hi Roy,
I am reviewing your post and I provide you some links for connectivity to
SQL Server. I wonder if it is helpful or if you still have questions about
it. For this question, the first step we do is check that the credentials
used to connect the SQL server is valid. ( information are valid as SQL
logins). If yes, then the problem might be related to IIS configuration or
some Windows security policies. You could ask for help from:
http://msdn.microsoft.com/newsgroups...icrosoft.publi
c.inetserver.iis
Hope this helps
Best regards
Baisong Wei
Microsoft Online Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.
|||I gave up and opened a support incident yesterday. After 4 hrs on the phone we thought it was resolved, but we were wrong.
On Thu, 01 Apr 2004 01:28:07 GMT, v-baiwei@.online.microsoft.com (Baisong Wei[MSFT]) wrote:

>Hi Roy,
>I am reviewing your post and I provide you some links for connectivity to
>SQL Server. I wonder if it is helpful or if you still have questions about
>it. For this question, the first step we do is check that the credentials
>used to connect the SQL server is valid. ( information are valid as SQL
>logins). If yes, then the problem might be related to IIS configuration or
>some Windows security policies. You could ask for help from:
>http://msdn.microsoft.com/newsgroups...icrosoft.publi
>c.inetserver.iis
>Hope this helps
>
>Best regards
>Baisong Wei
>Microsoft Online Support
>----
>Get Secure! - www.microsoft.com/security
>This posting is provided "as is" with no warranties and confers no rights.
>Please reply to newsgroups only. Thanks.
Roy Chastain
KMSystems, Inc.

Friday, February 10, 2012

Connection Problem trying to execute stored procedure

I am running the following code and getting the error below:

Dim connectionstringAsString ="<%$ ConnectionStrings:ConnectionString %>"Dim ConnectionAsNew SqlClient.SqlConnection(connectionstring)Dim CommandAsNew SqlClient.SqlCommand("StoredProcedure9", Connection)

Command.CommandType = Data.CommandType.StoredProcedure

Command.Parameters.Add(

New SqlClient.SqlParameter("@.bid_id", Data.SqlDbType.Int))

Command.Parameters(

"@.bid_id").Value ="Testing"

Connection.Open()

Command.ExecuteNonQuery()

Connection.Close()

ERROR:

Format of the initialization string does not conform to specification starting at index 0.

I think my connectionstring is wrong, please help.

Thanks

CAB

Try changing:
Dim connectionstringAsString ="<%$ ConnectionStrings:ConnectionString %>"

To

Dim connectionstring as String = System.Configuration.ConnectionStrings("MyConnectionStringName").ConnectionString (or something similar to that...)

Which will grab the connectionstring out of your web.config and plug it in as the property in question. (I'm not too up on VB.NET 2.0 so I may be wrong - but pretty sure you can't use the <% %> (i.e. pre-processing tags) inside of compilable VB.NET code - i.e. I think that's your issue)
|||

Hi,

Thanks for your help, but now I am getting:

'ConnectionStrings' is not a member of 'Configuration'.

Any ideas?

|||Cabby, can you let us know which version of the .NET Framework you are using? 1.1 or 2.0?|||

Hi, I am using version 2.0

I have updated that line of code to

Dim connectionstringAsString = System.Configuration.ConfigurationManager.AppSettings("connectionstring")

and am now getting:

The ConnectionString property has not been initialized.

This seems to be a similar problem tohttp://forums.asp.net/thread/402876.aspx but I am not sure I understand what needs to be done.

Please help!

Thanks

CAB

|||That other link was for ASP.NET 1.1. See if this article helps:Configuration API Improvements in ASP.NET 2.0
|||

Thanks for the link. But that seems to be working fine. When I run:

<%

@.ImportNamespace="System.Configuration" %>

<%

@.ImportNamespace="System.Web.Configuration" %>

<

scriptrunat=serverlanguage=C#>publicvoidPage_Load(objectsource,EventArgse)

{

Response.Write("Connection String:"

+

ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

}

</

script>

<

html>

<

head><title>Retrieving Connection Strings</title>

</

head>

<

body>

<

formid="form1"runat="server"><div></div>

</

form>

</

body>

</

html>

I get:

Connection String:Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True

Which I assume means all is working with that page.

But when I run my code:

ProtectedSub DetailsView1_ItemInserted(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.DetailsViewInsertedEventArgs)

Dim connectionstringAsString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")Dim ConnectionAsNew SqlClient.SqlConnection(connectionstring)Dim CommandAsNew SqlClient.SqlCommand("StoredProcedure9", Connection)

Command.CommandType = Data.CommandType.StoredProcedure

Command.Parameters.Add(

New SqlClient.SqlParameter("@.bid_id", Data.SqlDbType.Int))

Command.Parameters(

"@.bid_id").Value ="Testing"

Connection.Open()

Command.ExecuteNonQuery()

Connection.Close()

Response.Redirect(

"Default.aspx")EndSub

I get:

The ConnectionString property has not been initialized.

Any ideas?

Thanks

|||

UPDATE:

I have changed the connection string to:

Dim

connectionstringAsString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString()This seems to be getting a bit further, now my error is:

Input string was not in a correct format.

which seems to be relating to the line:

Command.ExecuteNonQuery()

any ideas?

Thanks, CAB

|||

The problem is with my parameters, the stored procedure works fine if I dont try and pass it any parameters and remove :

Command.Parameters.Add(New SqlClient.SqlParameter("@.bid_id", Data.SqlDbType.Int))

I have realised that I can do this all in the stored procedure and not have to pass any variables so now all is working fine.

Thanks for all the help!!!!!

CABBY