Showing posts with label connection. Show all posts
Showing posts with label connection. Show all posts

Thursday, March 29, 2012

HELP with connection string PLEASEEEE!

hi, I'm kind of really new to this. Trying to learn asp.net 2.0. Have been designing a website, and, so far so good, I can deploy the files, but I can't get the synthax right for the connection string. in my web.config file the connection string works on the local computer, but I can't figure out how to change the data source part:
this is what I have in my web convig file
<add name="Database2ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Documents and Settings\Alexi\My Documents\Delivery\web\App_Data\Database2.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" /
the the wrox book says I have to have the|datadirectory|
does it mean I have to write the full http address on the server?
and I can't figure out what to substitute in for the ".\sqlexpress" part...

my host has ms sql server 2000 and my sql. I asked for their support and the gave me a weird looking connection string and claimed that it worked...

<%@. LANGUAGE = JScript %>
<% var oConn;
oConn = Server.CreateObject("ADODB.Connection");
oConn.Mode = 3
oConn.Open("Provider=SQLOLEDB;Server=203.89.181.78;Database=alexeyka_yah_1951com_;UID=support;PWD=test123;");
%>
'

How can I, and where, copy my existing databse, and change the connection string?


Would really appreciate any help, perhaps buy a new book from the programmers in gratitude.

there is nothing wrong with connection string - the problem is that you are using database file with SQL express and you host SQL 2000 - so they will not be able to attach database file the way SQL Express does...

few days ago i posted why not to use database file with project that will go to shared hosting here:
http://forums.asp.net/thread/1375347.aspx - in the future login to SQL (express is cool) and create database then backup it and restore on your web hosting's SQL server

More info about connection strings you will find here:
http://www.connectionstrings.com/

If the database you have is empty no real data, then copy databse structure to new server change database2ConnectionString and you are good to go

your connections strin g will look like this

<add name="Database2ConnectionString" connectionString="Data Source=203.89.181.78;Initial Catalog=alexeyka_yah_1951com_;User ID=support;Password=test123;"
providerName="System.Data.SqlClient" />

BTW if that is real user pwd - CHANGE IT

|||

Hey, thank you so much for you help. Sorry for the late reply - didn't

The database does connect now, so all I have to do now is to figure out how to actually copy my database file to server.

Alexi;)

|||

if they offer SQL 2005 you should not have any problems. If not and you have to use SQL 2000 read this:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=71448&SiteID=1

|||

Hey, thanks again.

I was able to create an identical blank database table on the server in their asp.net enterprise manager. Yes, the do only have 2000 version.

Then, in VWD express I changed datasource control to point to the connection string that connects to the db on the server - it worked.

I'm struggling to contect to the database remotely, will hopefully figure something out.

Cheers again,

Alexi

|||

" I'm struggling to contect to the database remotely " ? - IF the hosting company accepts remote connections you can use free tool like SQL Server Managment Studio Express Edition to connect and work on you database. Keep in mind that many hoster block remote connections so you can only make changes to database design via online Enterprise manager or diffrent tool. If that is the case then simply change connection string in web config when you work on this application to you local machine, and before you do upload to server change it back to real SQL (the 2000 one)

|||

Hi Tom,

Thanks for you reply. I did download the sql server management studio, and asked whether my hosts allowed the remote connection - they don't. so I guess I have to do everything from scratch on the enterprise manager online. I've figured out normal tables, my main concern now will be to generate tables to store username/password info.

Cheers once again,

Alex

|||

one solution is to script everything

or the easy way will be :) :

http://forums.commercestarterkit.org/files/folders/sql_2000_upsize_scripts/entry471.aspx

|||

you can use this tool to add/edit/ delete users, create roles

http://peterkellner.net/2006/07/17/atlasjunectpsource/

make sure you secure it on the server, so u are the only one who can access it

|||

Hi Tom,

Thanks again for you input, have been real busy populating my datatables, so haven't had time to work on logins/users. If you like, you can check out the results of your efforts atwww.takeawaydelivery.co.nz

Will now be working my way into creating loging pages. By the way, the link that you gave me for some reason, it says there was a fata error and it couldn't be viewed? Anyway, thanks for all your help, and I'll let you know if I get around to creating users/etc

|||

the one with script or the one with tool to manage users ? i chcecked both links and are working just fine for me.

|||

Hi,

Seems to be working fine now, that was the tool to manage script. Downloaded it, and ran it. Works fine on my computer, though I can't understand though where are the usernames/passwords are stored. Also, with the tables, do I just run the whole script in the enterprise manager? and how do I link the two? Thanks again,

Alexi

|||

Hi,

an update here - the admin tool works fine on the local computer. I also reconfigured the weg.config file to point towards a remote database for users/passwords:

<membershipdefaultProvider="CustomizedProvider">

<providers>

<addname="CustomizedProvider"

type="System.Web.Security.SqlMembershipProvider"

connectionStringName="MyDB"

minRequiredPasswordLength="5"

minRequiredNonalphanumericCharacters="0" />

</providers>

</membership>

(and added a corresponding connection string).

For some reason though, when I run the table building script it doesn't show that anything is happening? like tables do not appear? any ideas-

thanks

Alexi

|||

Server Error in '/' Application.

Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

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.Data.SqlClient.SqlException: Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

Source Error:

Line 50: private void FindFirstUserName()Line 51: {Line 52: MembershipUserCollection muc = Membership.GetAllUsers();Line 53: foreach (MembershipUser mu in muc)Line 54: {


Source File:c:\Inetpub\vhosts\takeawaydelivery.co.nz\httpdocs\Default.aspx.cs Line:52

Stack Trace:

this is the erro when i go to the tool|||the database script (link i sent u) i used it few times and never had any problems with it - make sure that u can see all tables needed and stored proc.

Help with connection string

I have a connection string in my web.config file:
<add key="cnString" value="data source=ServerName;initial catalog=DatabaseName;password=Password;persist security info=True;user id=UserName;packet size=4096" />
and it works just fine with the SQL production server.
Recently the testing SQL server was created and I can login to it with Enterprise Manager.

But when I try to change the connection string just putting a new server name, database, user name, and password, it gives me the error:

Login failed for user 'UserName'

What should I look in the database or SQL server that is different from a production one? Or what should I ask since I don't have admin rights to both servers?

BTW, I've already tried to play with Trusted_Connection parameter (True/False) and it didn't help.

Thank you in advance for your help.You should check whether the user you are specifying in the connection string exists on the sql server and whether that user has access to the database that you are setting as "Initial catalog"

Hope that helps
Kashif|||Yes, the user exists and has an access to that database.

Tuesday, March 27, 2012

Help with Case

I have the following data with following conditions:

Old Type New Type

Number: 01 in table1 with Connection : 'J' in table2 'GE'

Number: 01 in table1 with Connection : 'K' in table2 'GPE'

Number: 01 in table1 with Connection: 'L' In table2 'GPA'

Number: 02 in table1 with Connection: 'I' in table2 'I02'

I used queries like:

SELECT CASE WHEN t1.Number = '01' THEN

CASE WHEN t2.Connection = 'J' THEN 'GE'

ELSE CASE WHEN t2.Connection = 'K' THEN 'GPE'

ELSE CASE WHEN t2.Connection = 'L' THEN 'GPA'

ELSE 'NOTHING' END END END END AS NewType

FROM Table1 AS t1 LEFT JOIN Table2 AS t2

ON (t1.ID = t2.ID).

I'll take an example:

An ID can have multiple connections attached to it. Let Say:

Table1 ID : 0001

Number: 01

Table2 ID: 0001

Connection: J, K, S, O, P.

Now, when i do the above query, i would get a result of 3 rows new case types for ID 0001.

I would like to just get one, and the first priority will be put on the condition of (GE).

everytime I see a Number '01' and Connection 'J', I would ignore the other connection. If i do not see Number = '01' and Connection: 'J'. i would go for the rest of the conditions.

Hope you guys see what problem i am having.

Thanks,

Jul.

Try this:

SELECT CASE WHEN t1.Number = '01' THEN

CASE WHEN t2.Connection = 'J' THEN 'GE'

WHEN t2.Connection = 'K' THEN 'GPE'

WHEN t2.Connection = 'L' THEN 'GPA'

ELSE 'NOTHING' END

END AS NewType

FROM Table1 AS t1 LEFT JOIN Table2 AS t2

ON (t1.ID = t2.ID)

Since I do not like repeating the condition, I would do this:

SELECT CASE WHEN t1.Number = '01' THEN

CASE t2.Connection WHEN 'J' THEN 'GE'

WHEN 'K' THEN 'GPE'

WHEN 'L' THEN 'GPA'

ELSE 'NOTHING' END

END AS NewType

FROM Table1 AS t1 LEFT JOIN Table2 AS t2

ON (t1.ID = t2.ID)

|||Still, i get multiple results.....Thanks though.|||So you want only one row returned?

SELECT CASE WHEN t1.Number = '01' THEN

CASE t2.Connection WHEN 'J' THEN 'GE'

WHEN 'K' THEN 'GPE'

WHEN 'L' THEN 'GPA'

ELSE 'NOTHING' END

END AS NewType

FROM Table1 AS t1 LEFT JOIN (

select id, min(Connection) [Connection]

from Table2

group by id) AS t2

ON (t1.ID = t2.ID)

|||It works....Thanks sooo much.....Smile

Monday, March 19, 2012

Help with a connection to a database

Hi

I have uptil now only used the WYSIWYG for retrieving info from my DB, but now i want to insert some information to the DB in a sub.

My connectionstring is in web.config and is as follows

 
<connectionStrings> <add name="shopConnectionString" connectionString="Data Source=IP.ADRESS.GOES.HERE;Initial Catalog=shop;Persist Security Info=True;User ID=MyId;Password=********" providerName="System.Data.SqlClient" /> </connectionStrings>
How do i connect to this connectionstring from inside a sub?

ConfigurationManager.ConnectionStrings["shopConnectionString"].ConnectionString

|||

Ok

Could you be a bit more specific?

for example

Sub add_click'connect to the DB' Execute SQL, for example: INSERT INTO table1 SELECT * FROM table2'close the connectionEnd Sub

That would be great, if you could help me with that.

|||

Dim scon as SqlConnecrion =new SqlConnection( ConfigurationManager.ConnectionStrings["shopConnectionString"].ConnectionString )

use this sql Connecton

|||

i'm getting an error "identifier expected"

Dim MyConn as SqlConnection =new SqlConnection( ConfigurationManager.ConnectionStrings["'<--errormessage
What could be wrong?|||

http://www.dotnetfun.com/articles/framework/2.0/WhatsNew20ConfigurationManager.aspx

See the tutorial to use the same and see where ur doing wrong

|||

Solved it!

Here's what worked for me.

Dim connAs SqlConnection conn =New SqlConnection(ConfigurationManager.ConnectionStrings("shopConnectionString").ConnectionString)
/jonas

Help with a connection string

I have a two computers, in one of them I install the SQL Server 2005 express with server name USER\SQLEXPRESS and ip 192.168.3.15.The data base name is Prueba.mdf

In the other computer I have VB 2005 express , and I want to connect with Prueba.mdf in the the other pc. Can you help me?

Hi

Try the below connection string settings

User ID=sa; ( if you configured your own, then replace user name and password acc)

password=sa;

Data Source=USER\SQLEXPRESS;

database=Prueba;

Connect Timeout=1800;

Regards,

Dhinesh Kumar

|||If you want to connect to a user instance, you should use one of the strings at www.connectionstrings.com , look for SQL Server 2005 and user instances, there are some strings which will help you.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

Sunday, February 26, 2012

HELP sql server 2005 express connection hangs up

Hi

I got an access 2002 application front end with a sql server 2005 express back end. Some of my clients are having some difficulties. After using the application for a while, some of the users are finding that the system just hangs up. It usually happens after the front end application has been running for about an hour (sometimes sooner and sometimes later). There are perhaps 1 to 5 concurrent users and I have checked to see if there are any firewalls stalling it (I think I check all of them)- Is there any way that SQL Server 2005 express could be caused to just stall- This even occurs with the odd laptop. All the appropriate protocols are enabled as well. These databses are not very large.

ANY HELP WOULD BE GREATLY APPRETIATED!!!

Thanks

Frank Srebot

Moved thread to the SQL Server Express forum.|||

hi Frank,

what do you mean by "just hangs up"? does it completely stalls requiring a reboot, or it's "sleeeping" for just a while and then restarts working "as expected" or the like?

to start, few things to consider..

SQLExpress sets the "autoclose" property of it's created databases to true, and this causes the dbs to be shut down when not in use, meaning that tyey will be closed if no active connection references them.. this involves a little overhead at next re-use as the dbs must be re-open, but I do not think this is your problem... anyway, the eventual related "problem" can be workaround modifying the relative database property via sp_dboption database's system stored procedure call...

"autoshrink" database property is even set to true, and this causes, at engine scheduled time frames, the eventual shrinking of the involved databases, so that when lots of insert/delete operations are performed (actually lots of deletes), the engine wakes up a thread to shrink (when necessary) the databases, requiring some time to execute..

if the autogrowth property of the database's datafiles and logfiles is set to true and the engine states new file space is required, the engine enlarges the files (when needed) and this will obviously involve some time as well...

other non SQL Server related issues includes OS's scheduled tasks requiring lots of CPU and/or I/O..

but it's hard to solve this way

regards

|||

Thanks for the great and quick response.

To clarify, sql server just hangs up meaning that the application displays an hourglass and eventually the sql connection is lost and an error message is given. I was doing some research and I was wondering if the problem could be in the connection pooling configuration- currently the setting are that pool connections are enabled by default in the ODBC config settings- the databases which I am dealing are quite small- would any one have any ideas perhaps along these lines?

Thanks

Frank srebot

|||

Hi

This is an update to my connection Problem with Access 2002 to SQL SERVER EXPRESS 2005.

We are having random disconnects on the client side with Access putting up a "Connection Failure" dialog box even when the user is actively entering records into the system. Have any of you ever encountered this situation? We have disabled all TCP offloading engine technology on the machine thinking this was causing a problem with SQL Server as well as changing network cards to a whole different brand. We've pretty much ruled out the physical network at this point because we have changed cables and moved to another port on a different switch to no avail.

Is there some timeout setting or connection pooling setting that I am unaware of at the SQL Server level that has a problem interacting with Windows Server 2003 or Windows XP? I have checked and double checked all of the server settings between the old machine and the new and they are identical.

I did read that the connection pooling may be stressed and the pool of connections are 'Leaking'. This might be due to a bad cable or connection, but thats all I have found out.

Any info would be greatly appreciated.

Thanks

Frank

Sunday, February 19, 2012

Help required Urgently: Intermittent connection failures

I am trying to connect to SQL Server from another box and I keep getting
this error intermittently.
DB-Library: Unable to connect: SQL Server is unavailable or does not exist.
Unable to connect: SQL Server does not exist or network access denied.
Net-Library error 10060: Connection (Connect()).
What could be the issues ?
-Nags
Hi,
This can be because of network issues. Can you execute a PING <Ipaddress>
command and
confirm that network is stable.
Thanks
Hari
MCDBA
"Nags" <nags@.DontSpamMe.com> wrote in message
news:eX2eXF#TEHA.3988@.TK2MSFTNGP10.phx.gbl...
> I am trying to connect to SQL Server from another box and I keep getting
> this error intermittently.
> DB-Library: Unable to connect: SQL Server is unavailable or does not
exist.
> Unable to connect: SQL Server does not exist or network access denied.
> Net-Library error 10060: Connection (Connect()).
> What could be the issues ?
> -Nags
>
|||Yes, we already tested it and the network is stable.
-Nags
"Hari" <hari_prasad_k@.hotmail.com> wrote in message
news:e2v4U7JUEHA.384@.TK2MSFTNGP10.phx.gbl...
> Hi,
> This can be because of network issues. Can you execute a PING <Ipaddress>
> command and
> confirm that network is stable.
> --
> Thanks
> Hari
> MCDBA
> "Nags" <nags@.DontSpamMe.com> wrote in message
> news:eX2eXF#TEHA.3988@.TK2MSFTNGP10.phx.gbl...
> exist.
>
|||Are these servers in the same subnet? Are they dual
homed? Perhaps the serving box is too busy? Perhaps a
bad patch cable? Are any other applications on this
server having problems connecting out?
Sincerly,
Invotion Engineering Team
Advanced Microsoft Hosting Solutions
http://www.Invotion.com
[vbcol=seagreen]
>--Original Message--
>Yes, we already tested it and the network is stable.
>-Nags
>"Hari" <hari_prasad_k@.hotmail.com> wrote in message
>news:e2v4U7JUEHA.384@.TK2MSFTNGP10.phx.gbl...
a PING <Ipaddress>[vbcol=seagreen]
box and I keep getting[vbcol=seagreen]
unavailable or does not[vbcol=seagreen]
network access denied.
>
>.
>
|||10060 = Connection Timeout.
Verify that the server doesn't have a personal firewall that is blocking
the client.
Make network traces on both the client and server and verify that the tcp 3
way handshake is completing.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.

Help required Urgently: Intermittent connection failures

I am trying to connect to SQL Server from another box and I keep getting
this error intermittently.
DB-Library: Unable to connect: SQL Server is unavailable or does not exist.
Unable to connect: SQL Server does not exist or network access denied.
Net-Library error 10060: Connection (Connect()).
What could be the issues ?
-NagsHi,
This can be because of network issues. Can you execute a PING <Ipaddress>
command and
confirm that network is stable.
Thanks
Hari
MCDBA
"Nags" <nags@.DontSpamMe.com> wrote in message
news:eX2eXF#TEHA.3988@.TK2MSFTNGP10.phx.gbl...
> I am trying to connect to SQL Server from another box and I keep getting
> this error intermittently.
> DB-Library: Unable to connect: SQL Server is unavailable or does not
exist.
> Unable to connect: SQL Server does not exist or network access denied.
> Net-Library error 10060: Connection (Connect()).
> What could be the issues ?
> -Nags
>|||Yes, we already tested it and the network is stable.
-Nags
"Hari" <hari_prasad_k@.hotmail.com> wrote in message
news:e2v4U7JUEHA.384@.TK2MSFTNGP10.phx.gbl...
> Hi,
> This can be because of network issues. Can you execute a PING <Ipaddress>
> command and
> confirm that network is stable.
> --
> Thanks
> Hari
> MCDBA
> "Nags" <nags@.DontSpamMe.com> wrote in message
> news:eX2eXF#TEHA.3988@.TK2MSFTNGP10.phx.gbl...
> exist.
>|||Are these servers in the same subnet? Are they dual
homed? Perhaps the serving box is too busy? Perhaps a
bad patch cable? Are any other applications on this
server having problems connecting out?
Sincerly,
Invotion Engineering Team
Advanced Microsoft Hosting Solutions
http://www.Invotion.com

>--Original Message--
>Yes, we already tested it and the network is stable.
>-Nags
>"Hari" <hari_prasad_k@.hotmail.com> wrote in message
>news:e2v4U7JUEHA.384@.TK2MSFTNGP10.phx.gbl...
a PING <Ipaddress>[vbcol=seagreen]
box and I keep getting[vbcol=seagreen]
unavailable or does not[vbcol=seagreen]
network access denied.[vbcol=seagreen]
>
>.
>|||10060 = Connection Timeout.
Verify that the server doesn't have a personal firewall that is blocking
the client.
Make network traces on both the client and server and verify that the tcp 3
way handshake is completing.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.

Help required in ASP.NET code

I am writting a very simple ASP.NET code, I am simlply trying toestablish a connection with the database in SQL Server 2000 and thanclosing the connection but still I am getting an exception,the name ofthe database is mydatabase, SQL Server 2000 is running in the windowsauthenticationfiltered=SSPI. The name of SQL Server 2000 runningonfiltered=xyz,
I checked the name from SQL Server Service Manager.Also I would like tostate here that I also tryed to establish a connection using C# and theconnection was successfully establish which means that there is noproblem with SQL Server also I sucessfully established the connectionwith MS Access and my ASP.NET application which proves that there is noproblem with IIS also.Also please check that the connection stringwhich I am providing is correct or not.The exception which I am gettingis as follows:
////////////

///////////////////////////////////////////////////////////////////
An exception occured while establishing connection
Login failed for user 'xyz\ASPNET'.
////////////////////////////////////////////////////////////////////////////
Please also note that I have a user with the name xyz/Administrator inthe logins of Sql Server 2000. Also note one more thing that the nameof my PC is xyz, I think that there is some problem with the connectionstring which i am providing so please especially check the connectionstring that either I have missed some thing or some thing has gonewrong,also please tell that are there any security restructions forASP.NET to access SQL Server 2000 or some thing like that which I haveto remove.The code is as follows:
//////////////////////////////////////////////////////////////////////////////////////
<%@. Page Language="C#" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>
void Page_Load(Object sender , EventArgs e)
{
try
{
SqlConfiltered=new SqlConnection("server=xyz;Integrated Security=SSPI;database=mydatabase;");
connection.Open();
Response.Write("<b>Connection is successfully established</b>");
connection.Close();
}
catch(Exception ex)
{
Response.Write("<b>An exception occured while establishing connection</b><br>"+" "+ex.Message.ToString());
}
}
</Script
The same above code is also present in the attachement file data.aspx ,please guide me where I am making mistake and please tell me that howcan I correct this mistake so that the code executes correctly.Alsoplease tell that what things should be included in the connectionstring and also please check the connection string of this code.

Connection string is fine if you intend to use Windows Authentication against SQl Server. User xyz/Administrator being in the logins has nothing to do with the error since you probably use that when connecting to SQL Server while working with Enterprise Manager interactively (e.g you use EM)

You have specified in connection string (Integrated Security=SSPI) that the Windows Identity ASP.NET runs under will also be used to log in to the given SQL Server instance. Your ASP.NEt application runs under "'xyz\ASPNET" identity which the error message

An exception occured while establishing connection
Login failed for user 'xyz\ASPNET'.

tries to indicate. Therefore this user should have its own login created to the SQL Server and again granted access to themydatabasedatabase given in the connection string.

What you need to do is to give this user the login and adequate permissions to the SQL Server instance by using SQL Server's management tools (Enterprise Manager)

help regarding SQL connection

i am developing a web application which requires a DB to store various data fields.
Though i am familiar with both web development languages and SQL, I am having difficulty connecting DB to my web pages(jsp). Can any one help with ODBC/JDBC settings required?

regards
sumit dagar

What kind of difficulties you are experiencing?

For an intro how to use JDBC to connect to SQL server see:

http://msdn2.microsoft.com/en-us/library/ms378672.aspx

|||i wanted to know if I have to change control panel->Administrative Tools->ODBC data sources settings.If yess then what would these settings be.

regards
Sumit Dagar