Showing posts with label express. Show all posts
Showing posts with label express. Show all posts

Tuesday, March 27, 2012

Connecting to SQL Server 2005 Express

I am having major issues connecting to SQL Server 2005 Express from Visual Basic 2005 Express, which I have tried on multiple PCs but to no avail. Can somebody please explain to me what I'm doing wrong?

1) I install SQL Server 2005 Express and Visual Basic 2005 Express (With .NET framework and SQL native client of course)
2) I open SQL Server using Management Studio and going in with windows authentication. It automatically sets the log on name to computername\SQLEXPRESS.
3) I create a new database called Test and add one table to it
4) I go into Visual Basic 2005 and create a new project.
5) I go to the projects application settings (Properties - Settings).
6) I set up a new connection string, choosing SQL server as the conection type and then on the Connection Properties window it asks me to select the mdf file for the database. I choose the file Test.mdf from the directory C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\
7) I click on Test Connection.

When I do this on two out of the three home PCs I get the error:
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Test.mdf".Operating system error 32: "32 (error not found)".
An attempt to attach an auto-named database for file C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Test.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

The third PC gives me a different error:

Cannot open user default database. Login failed. Login failed for user 'DAVE\David'.

I get the same errors when I try to use a connection string inside the code directly. Does anyone have a clue as to why these errors are occuring? Do I need to set up security or something else on the database first, or is there another reason? If anyone can please help me get to the bottom of this or provide a web address where I can get the answer (step by step instructions on how to connect) then I would be most grateful.

error code 32 means:
"The process cannot access the file because it is being used by another process."

So, either use a different file name for your connection in Visual Basic 2005, or try disconnect your connection in SQL Server using Management Studio.

|||

pse post the Connection string... it seems like u r trying to attach a db called Test....

in the second error .. check what is the Default Database given for user DAVE\David.... the default database should exists and this user should be a user of that db.... for debuggin purpose ... just change the default database of this user to Master and try... it will connect...

Madhu

|||

Hi, I get the same error as the original poster of this thread. I have no other database with similar name or anything, and i have not, as far as i know, any other connections to this database, since I just created it. Do you have any idea of how I should go about this?

Thanks

Niclas

sqlsql

Connecting to sql server 2005

I want to connect to database using sql server 2005 through Visual web developer 2005 express edition . what will be the connection string for this....

keywords under * * are for your own variable.

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ *datafile name *.mdf;Integrated Security=True;User Instance=True"

if it is a database in a local drive

and if you are using a web server ,

connectionString="data source=*ip address * ;user id=userid;password=pass"

|||

The following link might help you..

http://www.connectionstrings.com/?carrier=sqlserver2005

|||

sagar Khatri wrote:

keywords under * * are for your own variable.

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ *datafile name *.mdf;Integrated Security=True;User Instance=True"

if it is a database in a local drive

In fact that is not the right explanation. The above mentioned syntax is used when you use the SQL Server 2005 Express feature of user instances. The above mentioned sample assumes that yxou have a local SQL Server Express instance (configured with the instance name of SQLEXPRESS). User instances are used to temporary attach datafile to SQL Server instances.

sagar Khatri wrote:

and if you are using a web server ,

connectionString="data source=*ip address * ;user id=userid;password=pass"

This has nothing to do with a web server. The above mentioned syntax is used when you have a SQL Server attached database. No matter which middle tier (either an application you wrote or a web server is connecting to the database server)=, you are able to have multiple conenctions from multiple applications to this database, other then the user instance where only one application can create a user instance and have access to the database at a time.

Jens K. Suessmeyer

http://www.sqlserver2005.de

sqlsql

Connecting to SQL Server

Hi:

I installed SQL Express in one of my Notebook A (XP Pro SP2), I could start writing code with VB6 as it is in local machine (.\Sqlexpress)

At later stage, I used another Notebook B (XP pro SP1). I changed the notebook workgroup with the same name and try to connect to Notebook A with Ethernet Cable using SQLOLEDB to make connection, I had this Error Message

"Test Connection Failed because of an error initialising the provider.[DBNETLIB][Connection Open(Connect()).]SQL Server Does not Exist or Access Denied"

I look thru this forum, I quoted Jens K. Suessmeyer comment

This simply mean that in a network you either will need all users to have their own database OR dedicate a "server" (which can also be a workstation) to host the database as a server attached instance.

So I Presume I could used a PC/Notebook (not a Server) as Database Server?

If I used Windows NT Integrated Security, then I should create user accounts at Notebook A? Or Create User Accounts at SQL Server If i used "Used Specific User Name and Password" to Log in ?

My Intention is If I have 5 PC to log in to Server Automatically whenever they switch on the PC with the VB6 Program executing during start up. It make login to User as transparent as possible.

Thanks

"So I Presume I could used a PC/Notebook (not a Server) as Database Server?"

Yes, indeed you can.

If I used Windows NT Integrated Security, then I should create user accounts at Notebook A? Or Create User Accounts at SQL Server If i used "Used Specific User Name and Password" to Log in ?

If you are in a workgroup the (SQL Server) computers cannot verify the user of another computer as no trust exists between the computers (having the same workgroup name is not a trust). There is a workaround (I would name it hack), to use the same useraccount names and passwords on all computers to logon with Windows Authentication. I would suggest in that case to use SQL Server authentication instead.

"My Intention is If I have 5 PC to log in to Server Automatically whenever they switch on the PC with the VB6 Program executing during start up. It make login to User as transparent as possible."

Use SQL Server logins instead, if you don′t want any user interaction you should use a fixed user name to logon.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.d

Sunday, March 25, 2012

Connecting to sql from Delphi 5

I try to connect (locally) to SQLServer Express from Delphi5. On my developer computer, which has Windows XP, SQLServer 2000, VisualStudio2005 (and with that, SQLExpress 2005), it is no problem. However, when I transfer my program and the database to other computers with Windows 2000/WindowsServer2003 and a more recent standalone-version of SQLExpress, I get error messages like:

'Db-Library error 10004: No connection possible: SQL Server not available or not existing'

It does not matter which protocols I activate at the Server or whether the Server Browser service is running or not.

Does anybody have an idea how this might be fixed? Or whether it is a problem of the operating system?

Didi you try making a connecting without any Delphi tools like sqlcmd.exe at the command prompt ?

HTH, Jens K. Suessemeyer.

http://www.sqlserver2005.de
|||

Yes, all MS SQL 2005 tools work.

Meanwhile I found a solution myself: Everything works fine, if I install SQL Server 2000 additionally -- the client suffices. I don't like talking to a new 2005 database via an old 2000 client library, but at least it works.

Thanks very much for helping.

Lucia Lehr

connecting to SQL express through VB

Hi all,

I have SQL server express edition 2005 installed on my computer and using VB in MS Access to run some queries. The VB function looks something like this..

Dim dataRS As New ADODB.Recordset
Dim cnnSQL As New ADODB.Connection

Set cnnSQL = New ADODB.Connection
cnnSQL.ConnectionString = "Provider=SQLNCLI;Server=.\SQLExpress;Database=TestDB;Trusted_Connection=yes;"

cnnSQL.Properties("Integrated Security").Value = "SSPI"
cnnSQL.Open

dataRS.Open "SELECT dbo_Table_1.* FROM dbo_Table_1", cnnSQL, adOpenStatic, adLockOptimistic

The code fails on the last line with message
"Invalid object name 'dbo_Table_1'"
(yes, I verified that the table actually does exist in the DB)

I must be doing something wrong with the connection string but all the things that I've tried so far haven't worked.. Can anyone offer any suggestions?

Thanks in advance,

Try providing the schema name for the table in your select statement, as in:

SELECT DBO.dbo_Table1.* FROM DBO.dbo_Table1

You schema may or may not be DBO, I just use that here as an example.

Mike

Connecting to SQL Express on a hosted site

Folks.

I just moved my domain to GoDaddy.com. When I run my website locally, everything works fine.

When I ftp it to my server space on GoDaddy.com, I get a "remote connection" error. Does anyone have an example of a connection string I should be using to connect while on the server?

Thanks!

From looking at their website, they do not appear to offer SQL Server2005 or SQL Server 2005 Express. That'd be why you're getting theerror you are. I'm getting the same dang thing on my hostingservice - 1PlanHost.com. They, for some reason, will not installSQL Express... even though ALL of these starter kits, etc. are using itby default. It's making things quite bothersome for us developers!

If anyone figures out a way to force SQL Express to run within a shared hosting enviroment, let me know!|||

Thanks for your response. GoDaddy does offer SQL Server. You can configure it once you have purchased a hosting package. What they don't offer is any incling of support for it. If I find anything out, I'll let you know.

sqlsql

Connecting to SQL Express from C# via connection string

I created a SQL Express database from within Vistual Studio. It had a
property ConnectionString, so I grabbed that value and attempted to use it i
n
code. (I did add an @. at the beginning and doubled the literal double quote
symbols.) The code that assigns the connection string and opens the
connection then looked like the following:
SqlConnection cn = new SQLConnection();
cn.COnnectionString = @."Data Source=
.\SQLEXPRESS;AttachDBFilename=""C:\MySolution\MyData.mdf"";Integrated
Security=True;User Instance=True";
cn.Open();
SqlCommand myCommand = new SqlCommand("Use FTTestLocal Create Table Asset
(AssetID int Identity Not Null Primary Key, AssetName varchar(150) Not Null,
Modified TimeStamp)", cn);
int ct = myCommand.ExecuteNonQuery();
When I run the application I get an error when the command is executed
stating "Could not locate entry in sysdatabases for database 'FTTestLocal'.
No entry found with that name. Make sure the name is entered correctly."
Thanks in advance for any help.Your connection string is attaching one database named
C:\MySolution\MyData.mdf and then you are trying to create a table in a
database named FTTestLocal. Either your connection string is wrong or you
are trying to use the wrong database. Perhaps you should explain what
you're trying to do so we can tell which database is appropriate.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Steve Wash" <SteveWash@.discussions.microsoft.com> wrote in message
news:E426F5B2-E8E0-4D54-AAE2-949088D2A673@.microsoft.com...
>I created a SQL Express database from within Vistual Studio. It had a
> property ConnectionString, so I grabbed that value and attempted to use it
> in
> code. (I did add an @. at the beginning and doubled the literal double
> quote
> symbols.) The code that assigns the connection string and opens the
> connection then looked like the following:
> SqlConnection cn = new SQLConnection();
> cn.COnnectionString = @."Data Source=
> .\SQLEXPRESS;AttachDBFilename=""C:\MySolution\MyData.mdf"";Integrated
> Security=True;User Instance=True";
> cn.Open();
> SqlCommand myCommand = new SqlCommand("Use FTTestLocal Create Table Asset
> (AssetID int Identity Not Null Primary Key, AssetName varchar(150) Not
> Null,
> Modified TimeStamp)", cn);
> int ct = myCommand.ExecuteNonQuery();
> When I run the application I get an error when the command is executed
> stating "Could not locate entry in sysdatabases for database
> 'FTTestLocal'.
> No entry found with that name. Make sure the name is entered correctly."
> Thanks in advance for any help.
>|||Thanks for your quick review of my problem. I apologize that I made a
type-o, and your solution addresses the type-o. In trying to simplify my
example, I removed a lot of cryptic pathing information, but accidently left
in the "FTTestLocal". The actual code is
ConnectString=@."Data Source=.\SQLEXPRESS;AttachDbFilename=""C:\VS
Projects\Personal Utilities\TableClassBuilder\FTTestLocal.mdf"";Integrated
Security=True;User Instance=True";
The SQL command is "Use FTTestLocal Create Table Asset (AssetID int Identity
Not Null Primary Key, AssetName varchar(150) Not Null, Modified TimeStamp)"
I've also tried
"Use FTTestLocal.mdf Create Table Asset (AssetID int Identity Not Null
Primary Key, AssetName varchar(150) Not Null, Modified TimeStamp)".
Interestingly, the error message did not change at all. It did not seem to
pick up the .mdf in any way.
As for what I'm trying to accomplish, I'm attempting to modify existing
code. Currently the code attaches to an online server running MS SQL 2005
using the previously referenced code. I need to modify it to work as close
as possible to the same way but to instead attach to SQL Express. This way
I
can continue to develop without always needing to go online.|||Try running
SELECT name FROM sys.databases
to get the name of the database. It is probably:
C:\VSProjects\Personal Utilities\TableClassBuilder\FTTestLocal.mdf
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Steve Wash" <SteveWash@.discussions.microsoft.com> wrote in message
news:C92EB4DD-7189-487B-9BE9-03BD64B68ACA@.microsoft.com...
> Thanks for your quick review of my problem. I apologize that I made a
> type-o, and your solution addresses the type-o. In trying to simplify my
> example, I removed a lot of cryptic pathing information, but accidently
> left
> in the "FTTestLocal". The actual code is
> ConnectString=@."Data Source=.\SQLEXPRESS;AttachDbFilename=""C:\VS
> Projects\Personal Utilities\TableClassBuilder\FTTestLocal.mdf"";Integrated
> Security=True;User Instance=True";
> The SQL command is "Use FTTestLocal Create Table Asset (AssetID int
> Identity
> Not Null Primary Key, AssetName varchar(150) Not Null, Modified
> TimeStamp)"
> I've also tried
> "Use FTTestLocal.mdf Create Table Asset (AssetID int Identity Not Null
> Primary Key, AssetName varchar(150) Not Null, Modified TimeStamp)".
> Interestingly, the error message did not change at all. It did not seem
> to
> pick up the .mdf in any way.
>
> As for what I'm trying to accomplish, I'm attempting to modify existing
> code. Currently the code attaches to an online server running MS SQL 2005
> using the previously referenced code. I need to modify it to work as
> close
> as possible to the same way but to instead attach to SQL Express. This
> way I
> can continue to develop without always needing to go online.|||That was it. Thanks
"Roger Wolter[MSFT]" wrote:

> Try running
> SELECT name FROM sys.databases
> to get the name of the database. It is probably:
> C:\VSProjects\Personal Utilities\TableClassBuilder\FTTestLocal.mdf
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
> "Steve Wash" <SteveWash@.discussions.microsoft.com> wrote in message
> news:C92EB4DD-7189-487B-9BE9-03BD64B68ACA@.microsoft.com...
>
>

Connecting to SQL Express Database in C# Application

I'm trying to connect to a sql express database on my local machine, using the following connection string:

SqlConnection thisConnection = new SqlConnection(@."Data Source=C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Test.mdf");

However, I keep getting an error message saying "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections."

Why would my application be trying to connect remotely when the database is on my local machine? And how can I fix this problem?

Thanks

There 'should' be three major components to a connection string: source (or server), catalog (or database), and security information. You have only a source listed.

Check out legitimate SQL Server connection strings at: http://connectionstrings.com/?carrier=sqlserver2005

|||Thanks for the help!

Connecting to SQL Express 2005 via Web.Config file in Visual Studio 2003

Hi

I am following a project to build a small E-Commerce site from a book I have purchased and I have having problems connecting to the SQL Database with the code supplied.

The book is Apress Beginning ASP.NET 1.1 E-Commerce

http://www.amazon.co.uk/Beginning-ASP-Net-1-1-E-Commerce-Professional/dp/1590592549/ref=sr_11_1/202-7684451-7995058?ie=UTF8&qid=1193780707&sr=11-1

The code added to the Web.Config file is :

<configuration>

<appSettings>

<addkey="ConnectionString"value="Server=(local)\NetSDK;Integrated Security=True;Initial Catalog=JokePoint"/>

</appSettings>

The connection details are in a class file called Catalog.vb and is as follows

Imports System.Data.SqlClient

PublicClass Catalog

PublicSharedFunction GetDepartments()As SqlDataReader

'Create the connection object

Dim connectionAsNew SqlConnection(connectionString)

'Create and initialize the command object

Dim commandAsNew SqlCommand("GetDepartments", connection)

command.CommandType = CommandType.StoredProcedure

'Open the connection

connection.Open()

'Return a SqlDataReader to the calling function

Return command.ExecuteReader(CommandBehavior.CloseConnection)

EndFunction

PrivateSharedReadOnlyProperty connectionString()AsString

Get

Return ConfigurationSettings.AppSettings("ConnectionString")

EndGet

EndProperty

EndClass

The error is....

Cannot open database "JokePoint" requested by the login. The login failed. Login failed for user 'MachineName\ASPNET'.

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: Cannot open database "JokePoint" requested by the login. The login failed. Login failed for user 'MachineName\ASPNET'.

Source Error:

Line 15: 'Open the connectionLine 16:Line 17: connection.Open()Line 18: Line 19: 'Return a SqlDataReader to the calling function


Source File:C:\MyCommerceSite\JokePoint\BusinessObjects\Catalog.vb Line:17

Stack Trace:

[SqlException: Cannot open database "JokePoint" requested by the login. The login failed.Login failed for user 'MachineName\ASPNET'.] System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) System.Data.SqlClient.SqlConnection.Open() JokePoint.Catalog.GetDepartments() in C:\MyCommerceSite\JokePoint\BusinessObjects\Catalog.vb:17 JokePoint.DepartmentsList.Page_Load(Object sender, EventArgs e) in C:\MyCommerceSite\JokePoint\UserControls\DepartmentsList.ascx.vb:44 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Control.LoadRecursive() System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain()

The connection tests ok in Visual Studio 2003. All permissions are set using SQL Management Studio Express 2005.

The book is using SQL 2000, I have been trying different connection syntax's in the Web.Config file all day and now I have a big headache. I know its something simple, can anyone please advise ?

Thanks in advance.

Mark

cracken:

<addkey="ConnectionString"value="Server=(local)\NetSDK;Integrated Security=True;Initial Catalog=JokePoint"/>

First, you are trying to connect using windows authentication and not with a SQL Server user credentials. I think the Integrated Security part is causing you the error. Have you tried to connect using SQL Server user credentials ( if any ), or you are using the windows authentication only.

Hope this will help.

|||

Try this...

web.config file:

<connectionStrings>

<addname="ConnectionString";Data Source=(local)\NetSDK;Integrated Security=True;Initial Catalog=JokePoint";

providerName="System.Data.SqlClient" />

</connectionStrings>

after that in the vb page:

Dim sepAsNew SqlConnection("connectionstring")

sep.Open()

Dim commandAsNew SqlCommand("GetDepartments", sep)

command.CommandType = CommandType.StoredProcedure

|||

Hi

Thanks for answering so quick, I am using Windows Integrated Secuity at the moment.

I have tried the suggestion above, but they were not sucessful. What I have done is changed the provier to OleDb and added a bit to the connection string.

I do not seen to get any code errors now, just login errors.

The VB file now looks like:

Imports System.Data

Imports System.Data.OleDb.OleDbConnection

Public Class Catalog

Public Shared Function GetDepartments() As OleDb.OleDbDataReader

'Create the connection object

Dim connection As New OleDb.OleDbConnection(connectionString)

'Create and initialize the command object

Dim command As New OleDb.OleDbCommand("GetDepartments", connection)

command.CommandType = CommandType.StoredProcedure

'Open the connection

connection.Open()

'Return a OleDbDataReader to the calling function

Return command.ExecuteReader(CommandBehavior.CloseConnection)

End Function

Private Shared ReadOnly Property connectionString() As String

Get

Return ConfigurationSettings.AppSettings("ConnectionString")

End Get

End Property

End Class

And the Web.Config connection string :

<configuration>

<appSettings>

<addkey="connectionString"value="Server=(local)\NetSDK; Provider=SQLOLEDB; Integrated Security=SSPI; Initial Catalog=JokePoint"/>

</appSettings>

And the error message :

Cannot open database "JokePoint" requested by the login. The login failed.

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.OleDb.OleDbException: Cannot open database "JokePoint" requested by the login. The login failed.

Source Error:

Line 16: 'Open the connectionLine 17:Line 18: connection.Open()Line 19: Line 20: 'Return a OleDbDataReader to the calling function

All access accounts and read / write permission are correct.

Any more advise would be much app.

Regards

Mark

connecting to SQL DATABASE ENGINE

hello everybody!!!

I am very new to SQL SERVER 2005 EXPRESS EDITION

while connecting to DATABASE ENGINE i got this error message.....

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (.Net SqlClient Data Provider)

any solution please?

Hi,

If you are trying on a local machine.

login properly :

server instance: computer_name\SQLSERVER_INSTANCE_NAME

user name : computer_name\user_name

If trying on a remote machine:

have a look in the following link:

http://blogs.msdn.com/sqlexpress/archive/2005/05/05/415084.aspx

Hope it'll help.

|||

this error is very common... You check whether the instance is configured for Remote connection

Start --Microsoft sql server 2005-- Configuration Tools -- SQL Server Surface Area Configuration -- Surface Area configuration for services and connections -- Select Remote Connection -- Select Local and remote connection Radio button and using both TCP/IP and named pipes

ALso check whether the firewall is enabled. if yes create exception for 1433 and 1434

Madhu

sqlsql

Thursday, March 22, 2012

Connecting to some remote Sql Server

Hi

I've got a desktop and a notebook and both are connected to the router. On both I've got Sql Server Express and Sql Server Management Studio Express installed. I need to connect to a remote Sql Server (using user ID and password) which works fine on my desktop, but fails on my notebook: Error:0 and Error: 10060.

I checked all router settings and notebook settings, but I don't know what I am doing wrong. I got myself another notebook and installed Sql Server Express plus Management Studio, which did not work either.

Hopefully someone can help.

Thank you.

The error code is of Socket error. It seems you are not able to get connected to your SQL server.

following should help you.

http://www.dameware.com/support/kb/article.aspx?ID=300060

|||

Hi, I am able to connect to the local Sql Server Express (running on the notebook) - only remote connections (at least the one I am trying) fail.

Thanks!

|||

The remote connection may be failing because of socket error. You might like to have a look at remote connection. You might also like to look at the SQL server to check if it allows remote connections.

connecting to server but not to database-Newbie Question

Hi everyone,

I created a database in SSMS,but I can't connect to it using VB Express code.When I delete the database name from the server I can connect to server,but when I mention the name of the database or initial catalog,I receive a login failure error for the mentioned database...

My connection string is:

Dim conn1 As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;initial catalog=TEST1;" _

& "Integrated Security=True;" & "user instance=true;")

Everything is Local,I am using express version of SQL server and VB.How I am not be able to connect the database I created under the server in SSMS...I am really confused...

Thanks in advance!!!!

Can

What is the exact error message you are getting ?

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de
|||

Hallo Mr Suessmeyer,

Yesterday you had also replied my question but I can't go ayn further.I downloaded SSMS,craeted a database under the server but I still get this error...How can I gain the access rights to the database that I created?

" Die von der Anmeldung angeforderte "database1"-Datenbank kann nicht ge?ffnet werden. Fehler bei der Anmeldung.
Fehler bei der Anmeldung für den Benutzer 'ADPLAN\atalay'. "

This was from the company's PC (where I write my thesis) I have a windows user account there...I also tried at home,I am the only user for windows XP at home but anyways I can not connect to the database,receiving the same error message.As I had written before if I leave Initial catalog= or database= fields empty then I am able to connect to the server...

Thanky in advance!

Can

|||

For a quick one, try to add the user to the sysadmin group to let him access the database (if it is based on a security issue)

sp_addsrvrolemember [ @.loginame= ] 'login'
, [ @.rolename = ] 'role'


For granular configuration, use the following procedure to grant him access to the db (not any objects so far)

sp_grantlogin [@.loginame=] 'login'
sp_defaultdb [ @.loginame = ] 'login', [ @.defdb = ] 'database'
sp_grantdbaccess [ @.loginame = ] 'login'
[ , [ @.name_in_db = ] 'name_in_db' [ OUTPUT ] ]

The same can be done within the Managment Studio.

HTH, Jens Suessmeyer.


http://www.sqlserver2005.de


|||

Thank you for the reply but I don't know where to enter this code...It'd be kind of you if you'd give more details,I am not a programmer which makes the things more difficult for me...

Regards,

Can

|||

Hi,

no problem, download SQL Server Express Management Studio and execute the query within the Studio (there is a function to open a "New Query". Then type in the command with the appropiate values fitting to your production system.
Download via: http://msdn.microsoft.com/vstudio/express/sql/download/


HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||

hi,

I do think all this is related to the fact you are just using a user instance (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/sqlexpuserinst.asp)..

on the other side, when you execute SSMSE it usually connects to the "traditional" SQLExpress edition you installed, and these are 2 different instances..

regards

|||

Thank you for all your replies.I solved my problem using SQL server management studio and using this query:

Use TEST1
go
exec sp_addlogin loginname,password,TEST1
go
exec sp_helplogins
go

then I added to this login to the database I wanted to connect,and I had to add login name and password to connection string(instead of user instances and integrated security).

Now it works this way.

Regards,

Can

Tuesday, March 20, 2012

Connecting to remote Express instance using SSMS

I have a server running SQL Server 2005 Ent. Ed. SP2 and locally, I can see
the default instance and two SQLExpress instances named 'sqlexpress' and
'officeservers', all withing SSMS, and can connect and manage them.
From my workstation, running SQL 2005 Dev, SP2, I can connect to the default
instance on that server, but cannot connect to the express instances. They
both have TCP/IP protocol enabled, along with "Allow Remote COnnections".
I have done the following:
Made myself a member of the local Admin group
Tried using the sa account to connect
nothing seems to work. What am I missing?
TIA
Todd Chittenden
Is the SQLBrowser Service enabled and started?
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Todd C" <ToddC@.discussions.microsoft.com> wrote in message
news:15C51BF6-FF25-435E-B26B-3863344FB81D@.microsoft.com...
>I have a server running SQL Server 2005 Ent. Ed. SP2 and locally, I can see
> the default instance and two SQLExpress instances named 'sqlexpress' and
> 'officeservers', all withing SSMS, and can connect and manage them.
> From my workstation, running SQL 2005 Dev, SP2, I can connect to the
> default
> instance on that server, but cannot connect to the express instances. They
> both have TCP/IP protocol enabled, along with "Allow Remote COnnections".
> I have done the following:
> Made myself a member of the local Admin group
> Tried using the sa account to connect
> nothing seems to work. What am I missing?
> TIA
> --
> Todd Chittenden
>
|||I found it not long after posting the original question:
No, the Browser service was not running. Starting that up enabled me to
connect to it. So that was the answer.
But even before the Enterprise instance was installed, (which includes the
browser service) I was not able to connect. I know I have other machines in
my domain that are running SQL Express. Should I not be able to connect to
them using my SSMS? What do I need to do to make that happen?
I assume that I need membership in the group on the local machine that bears
the SQL Express instance name?
What else? I can't rely on the Browser service in those instances.
Thanks
Todd Chittenden
"Roger Wolter[MSFT]" wrote:

> Is the SQLBrowser Service enabled and started?
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
> "Todd C" <ToddC@.discussions.microsoft.com> wrote in message
> news:15C51BF6-FF25-435E-B26B-3863344FB81D@.microsoft.com...
>
|||SQL Express by default installs as a named instance. Unless you specify the
TCP/IP port in the connection string, you need the sqlbrowser service to
connect to a named instance.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Todd C" <ToddC@.discussions.microsoft.com> wrote in message
news:F4B981A2-4B9A-443E-855B-D53B89FCE511@.microsoft.com...[vbcol=seagreen]
>I found it not long after posting the original question:
> No, the Browser service was not running. Starting that up enabled me to
> connect to it. So that was the answer.
> But even before the Enterprise instance was installed, (which includes the
> browser service) I was not able to connect. I know I have other machines
> in
> my domain that are running SQL Express. Should I not be able to connect to
> them using my SSMS? What do I need to do to make that happen?
> I assume that I need membership in the group on the local machine that
> bears
> the SQL Express instance name?
> What else? I can't rely on the Browser service in those instances.
> Thanks
> --
> Todd Chittenden
>
> "Roger Wolter[MSFT]" wrote:

Connecting to remote Express instance using SSMS

I have a server running SQL Server 2005 Ent. Ed. SP2 and locally, I can see
the default instance and two SQLExpress instances named 'sqlexpress' and
'officeservers', all withing SSMS, and can connect and manage them.
From my workstation, running SQL 2005 Dev, SP2, I can connect to the default
instance on that server, but cannot connect to the express instances. They
both have TCP/IP protocol enabled, along with "Allow Remote COnnections".
I have done the following:
Made myself a member of the local Admin group
Tried using the sa account to connect
nothing seems to work. What am I missing?
TIA
--
Todd ChittendenIs the SQLBrowser Service enabled and started?
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Todd C" <ToddC@.discussions.microsoft.com> wrote in message
news:15C51BF6-FF25-435E-B26B-3863344FB81D@.microsoft.com...
>I have a server running SQL Server 2005 Ent. Ed. SP2 and locally, I can see
> the default instance and two SQLExpress instances named 'sqlexpress' and
> 'officeservers', all withing SSMS, and can connect and manage them.
> From my workstation, running SQL 2005 Dev, SP2, I can connect to the
> default
> instance on that server, but cannot connect to the express instances. They
> both have TCP/IP protocol enabled, along with "Allow Remote COnnections".
> I have done the following:
> Made myself a member of the local Admin group
> Tried using the sa account to connect
> nothing seems to work. What am I missing?
> TIA
> --
> Todd Chittenden
>|||I found it not long after posting the original question:
No, the Browser service was not running. Starting that up enabled me to
connect to it. So that was the answer.
But even before the Enterprise instance was installed, (which includes the
browser service) I was not able to connect. I know I have other machines in
my domain that are running SQL Express. Should I not be able to connect to
them using my SSMS? What do I need to do to make that happen?
I assume that I need membership in the group on the local machine that bears
the SQL Express instance name?
What else? I can't rely on the Browser service in those instances.
Thanks
--
Todd Chittenden
"Roger Wolter[MSFT]" wrote:

> Is the SQLBrowser Service enabled and started?
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
> "Todd C" <ToddC@.discussions.microsoft.com> wrote in message
> news:15C51BF6-FF25-435E-B26B-3863344FB81D@.microsoft.com...
>|||SQL Express by default installs as a named instance. Unless you specify the
TCP/IP port in the connection string, you need the sqlbrowser service to
connect to a named instance.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Todd C" <ToddC@.discussions.microsoft.com> wrote in message
news:F4B981A2-4B9A-443E-855B-D53B89FCE511@.microsoft.com...[vbcol=seagreen]
>I found it not long after posting the original question:
> No, the Browser service was not running. Starting that up enabled me to
> connect to it. So that was the answer.
> But even before the Enterprise instance was installed, (which includes the
> browser service) I was not able to connect. I know I have other machines
> in
> my domain that are running SQL Express. Should I not be able to connect to
> them using my SSMS? What do I need to do to make that happen?
> I assume that I need membership in the group on the local machine that
> bears
> the SQL Express instance name?
> What else? I can't rely on the Browser service in those instances.
> Thanks
> --
> Todd Chittenden
>
> "Roger Wolter[MSFT]" wrote:
>

Monday, March 19, 2012

Connecting to MS SQL DB in other server ?

Hello, All

I have been checking out VB Express for over a week now and I have to say, Im very happy with this Software. Thanks MS

Ok, so far so good I have created a basic APP for use in my office that contains information about clients. Now what I just cant get is, How do I connect to a SQL DB that is in a server at a hosting company ? I have created the DB in the server and all tables now how do I get the connection going ? If any anyone can show me how to do it I would appreciate it or if you can show me a link to a site that has steps by step that would be cool also.

Thank you for your help,

You have to define the conenction string to point to the external server / database: For connectionstrings you can look up the information an www.connectionstrings.com.

You have to know the public adress of the server like the ip adress or the dns name and if you use a default instance or not.

Data Source=81.100.29.81;Initial Catalog=pubs;User Id=sa;Password=asdasd;" --OR

Data Source=81.100.29.81\InstanceName;Initial Catalog=pubs;User Id=sa;Password=asdasd;" --For a named instance.

HTH, jens Suessmeyer.

Connecting to local SQL Server

Hi,

I am having problems connecting to databases on my local SQL Server, express edition from my website.

The following is the connection string i am using:

Database=MyDatabase;Server=COMP\SQLEXPRESS;User ID=sa;

The error I get is "Login failed for sa"

I have tried other users but no luck. Also, I cant seem to create a new user as I don't have administrators rights, any ideas how i can do this?

Any ideas?

did you try it this way

<add name="CommerceTemplate" connectionString="Data Source=Comp.Name\SQLEXPRESS;Initial Catalog=dbname;Trusted_Connection=True;"
providerName="System.Data.SqlClient" />

hope this helps

|||

see

www.connectionstrings.com

for help

|||

Hi,

From your description, it seems that you are using "sa" account to log in your SQLServer, that is to say you have set your SQLServer as "SQL Mixed Authentication mode", right?

Based on the error message, there are two possibilities. First, try to log into your SQLServer by SQLServer Management Studio with the 'sa' account, to see if it can work. If not, I guess the account and password maybe invalid. Second, if you are using Windows Authentication mode, you should also make your connection string looks like:

"data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"

Thanks.

Connecting to Local Database after Application Install

I have created an application which uses a SQL Express database. The program runs fine on the the computer where I built the app, however when I install the app on another computer I get an error telling me that under default SQL Express does not allow remote connections. The problem is that I dont want a remote connection I want a local connection, the database file is on the commputer. How can do get my application to look for the database on the local machine.

My connection string is:

Data Source=(local)\SQLEXPRESS;Initial Catalog="C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR\PLDAQ.MDF";Integrated Security=True

I have made sure that the file is in the correct directory.

Any help would be greatly appretiated

hi,

the folder you are referencing is not a "standard" one in the "traditional" sense of SQL Server, and you can get problems if the account running the instance is not able to access that path... and anyway you should reference the intital catalog in the connection string via the "logical" name and not the physical primary data file name, thus
Data Source=(local)\SQLEXPRESS;Initial Catalog=dbLogicalFileName;Integrated Security=True
or use the AttachDBFilename feature of the User Instances mode..

try modifying the connection string to see if you are granted connection to the instance you are dealing with, as the exception you are reporting is quite a generic connection exception..

regards

|||

Andrea

I still have the same problem, I have updated my connection string to this:

Data Source = .\SQLEXPRESS;AttachDBFilename = [DataDirectory]\PLDaq.mdf;Integrated Security = True; UserInstance = False

I have managed to get arround the error by changeing the name of the non-design computer to mach the name of the design computer, this however, as I am sure you will agree, is only temporary as I don't want to have to change the name of every computer that I install this application on, what do I need to do to rectify this situation.

|||

hi,

as you are not using "User Instances", I'd not go for the AttachDBFileName property of the connection string.. I'd attach/create the database once and then I'd go for the "traditional" Database=yourDbName property of the connection string...

I have managed to get arround the error by changeing the name of the non-design computer to mach the name of the design computer

do you mean by that you "named" the destination computer the same as your dev pc? this is obviously not "mandatory"...

what is your |DataDirectory| value?

regards

|||

do you mean by that you "named" the destination computer the same as your dev pc? this is obviously not "mandatory"...

Unfortunatly this is the only way it will not generate the error posted above. Like I said the program is looking for a remote connection but I want a local one. So I tricked it into thinking that it was running on the dev computer by changeing the name. I will agree that this is obviously not convient, but that is why I am posting I just cant figure out how to fix it.

The |DataDirectory| tells the connection to look in the bin\debug folder during dev time, and also to look into the bin\data folder at run time, after installation obviously. So when the program is installed and all data files are stored in the (AppPath)\bin\data directory and that is where the program is supposed to look for the data files (e.g. Database and Log files), however, if the non dev computer has a different name it trys to find the dev computer to connect to the database, a remote connection, It cant do this as it is not connected to any network.

I have tryed the traditional Database = yourDbName and that causes the same problem

Also There may come a time when I want to use User Instances, but for the time being I just want the thing to work.

|||

PEng1 wrote:

Unfortunatly this is the only way it will not generate the error posted above. Like I said the program is looking for a remote connection but I want a local one. So I tricked it into thinking that it was running on the dev computer by changeing the name. I will agree that this is obviously not convient, but that is why I am posting I just cant figure out how to fix it.

the fix is using

Data Source = .\SQLEXPRESS or Data Source = (Local)\SQLEXPRESS property in the connection string...

here you have to specify the instance you have to connect to, and you can provide "." and/or "(Local)" for "local" connections"...

The |DataDirectory| tells the connection to look in the bin\debug folder during dev time, and also to look into the bin\data folder at run time, after installation obviously. So when the program is installed and all data files are stored in the (AppPath)\bin\data directory and that is where the program is supposed to look for the data files (e.g. Database and Log files), however, if the non dev computer has a different name it trys to find the dev computer to connect to the database, a remote connection, It cant do this as it is not connected to any network.

pay attention to your "custom data folder"... consider that the account running the SQLExpress intstance required adeguate NTFS permissions to that folder.. and consider Vista "headaches"/requirements with regard writing in Program Files folder...

regards

|||

Andrea,

I guess that I had the answer for a while and just didn't bother to check if it would work with a different name, or I changed something and just don't remeber what, probably the latter of the two, either way, the problem is resolved and I am greatly indebted for all of your help. Thanks a lot.

This program will be run on Windows 2000 for quite a while but it will eventually have to be moved to Vista or higher, what "headaches" are you refering to, I am not at all familiar with Vista since the company I work for still has some machines that are running 95 and One that is running DOS, yeah thats right I said DOS. I guess however that I should probably read up on the New OS any recomended reading?

|||

hi,

PEng1 wrote:

Andrea,

I guess that I had the answer for a while and just didn't bother to check if it would work with a different name, or I changed something and just don't remeber what, probably the latter of the two, either way, the problem is resolved and I am greatly indebted for all of your help. Thanks a lot.

This program will be run on Windows 2000 for quite a while but it will eventually have to be moved to Vista or higher, what "headaches" are you refering to, I am not at all familiar with Vista since the company I work for still has some machines that are running 95 and One that is running DOS, yeah thats right I said DOS. I guess however that I should probably read up on the New OS any recomended reading?

start reading at http://technet.microsoft.com/en-us/windowsvista/aa905108.aspx, http://technet.microsoft.com/en-us/windowsvista/aa906021.aspx, ....

and look in this forum for Vista troubles with UAC..

regards

Connecting to Local Database after Application Install

I have created an application which uses a SQL Express database. The program runs fine on the the computer where I built the app, however when I install the app on another computer I get an error telling me that under default SQL Express does not allow remote connections. The problem is that I dont want a remote connection I want a local connection, the database file is on the commputer. How can do get my application to look for the database on the local machine.

My connection string is:

Data Source=(local)\SQLEXPRESS;Initial Catalog="C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR\PLDAQ.MDF";Integrated Security=True

I have made sure that the file is in the correct directory.

Any help would be greatly appretiated

hi,

the folder you are referencing is not a "standard" one in the "traditional" sense of SQL Server, and you can get problems if the account running the instance is not able to access that path... and anyway you should reference the intital catalog in the connection string via the "logical" name and not the physical primary data file name, thus
Data Source=(local)\SQLEXPRESS;Initial Catalog=dbLogicalFileName;Integrated Security=True
or use the AttachDBFilename feature of the User Instances mode..

try modifying the connection string to see if you are granted connection to the instance you are dealing with, as the exception you are reporting is quite a generic connection exception..

regards

|||

Andrea

I still have the same problem, I have updated my connection string to this:

Data Source = .\SQLEXPRESS;AttachDBFilename = [DataDirectory]\PLDaq.mdf;Integrated Security = True; UserInstance = False

I have managed to get arround the error by changeing the name of the non-design computer to mach the name of the design computer, this however, as I am sure you will agree, is only temporary as I don't want to have to change the name of every computer that I install this application on, what do I need to do to rectify this situation.

|||

hi,

as you are not using "User Instances", I'd not go for the AttachDBFileName property of the connection string.. I'd attach/create the database once and then I'd go for the "traditional" Database=yourDbName property of the connection string...

I have managed to get arround the error by changeing the name of the non-design computer to mach the name of the design computer

do you mean by that you "named" the destination computer the same as your dev pc? this is obviously not "mandatory"...

what is your |DataDirectory| value?

regards

|||

do you mean by that you "named" the destination computer the same as your dev pc? this is obviously not "mandatory"...

Unfortunatly this is the only way it will not generate the error posted above. Like I said the program is looking for a remote connection but I want a local one. So I tricked it into thinking that it was running on the dev computer by changeing the name. I will agree that this is obviously not convient, but that is why I am posting I just cant figure out how to fix it.

The |DataDirectory| tells the connection to look in the bin\debug folder during dev time, and also to look into the bin\data folder at run time, after installation obviously. So when the program is installed and all data files are stored in the (AppPath)\bin\data directory and that is where the program is supposed to look for the data files (e.g. Database and Log files), however, if the non dev computer has a different name it trys to find the dev computer to connect to the database, a remote connection, It cant do this as it is not connected to any network.

I have tryed the traditional Database = yourDbName and that causes the same problem

Also There may come a time when I want to use User Instances, but for the time being I just want the thing to work.

|||

PEng1 wrote:

Unfortunatly this is the only way it will not generate the error posted above. Like I said the program is looking for a remote connection but I want a local one. So I tricked it into thinking that it was running on the dev computer by changeing the name. I will agree that this is obviously not convient, but that is why I am posting I just cant figure out how to fix it.

the fix is using

Data Source = .\SQLEXPRESS or Data Source = (Local)\SQLEXPRESS property in the connection string...

here you have to specify the instance you have to connect to, and you can provide "." and/or "(Local)" for "local" connections"...

The |DataDirectory| tells the connection to look in the bin\debug folder during dev time, and also to look into the bin\data folder at run time, after installation obviously. So when the program is installed and all data files are stored in the (AppPath)\bin\data directory and that is where the program is supposed to look for the data files (e.g. Database and Log files), however, if the non dev computer has a different name it trys to find the dev computer to connect to the database, a remote connection, It cant do this as it is not connected to any network.

pay attention to your "custom data folder"... consider that the account running the SQLExpress intstance required adeguate NTFS permissions to that folder.. and consider Vista "headaches"/requirements with regard writing in Program Files folder...

regards

|||

Andrea,

I guess that I had the answer for a while and just didn't bother to check if it would work with a different name, or I changed something and just don't remeber what, probably the latter of the two, either way, the problem is resolved and I am greatly indebted for all of your help. Thanks a lot.

This program will be run on Windows 2000 for quite a while but it will eventually have to be moved to Vista or higher, what "headaches" are you refering to, I am not at all familiar with Vista since the company I work for still has some machines that are running 95 and One that is running DOS, yeah thats right I said DOS. I guess however that I should probably read up on the New OS any recomended reading?

|||

hi,

PEng1 wrote:

Andrea,

I guess that I had the answer for a while and just didn't bother to check if it would work with a different name, or I changed something and just don't remeber what, probably the latter of the two, either way, the problem is resolved and I am greatly indebted for all of your help. Thanks a lot.

This program will be run on Windows 2000 for quite a while but it will eventually have to be moved to Vista or higher, what "headaches" are you refering to, I am not at all familiar with Vista since the company I work for still has some machines that are running 95 and One that is running DOS, yeah thats right I said DOS. I guess however that I should probably read up on the New OS any recomended reading?

start reading at http://technet.microsoft.com/en-us/windowsvista/aa905108.aspx, http://technet.microsoft.com/en-us/windowsvista/aa906021.aspx, ....

and look in this forum for Vista troubles with UAC..

regards

Connecting to Local Database after Application Install

I have created an application which uses a SQL Express database. The program runs fine on the the computer where I built the app, however when I install the app on another computer I get an error telling me that under default SQL Express does not allow remote connections. The problem is that I dont want a remote connection I want a local connection, the database file is on the commputer. How can do get my application to look for the database on the local machine.

My connection string is:

Data Source=(local)\SQLEXPRESS;Initial Catalog="C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR\PLDAQ.MDF";Integrated Security=True

I have made sure that the file is in the correct directory.

Any help would be greatly appretiated

hi,

the folder you are referencing is not a "standard" one in the "traditional" sense of SQL Server, and you can get problems if the account running the instance is not able to access that path... and anyway you should reference the intital catalog in the connection string via the "logical" name and not the physical primary data file name, thus
Data Source=(local)\SQLEXPRESS;Initial Catalog=dbLogicalFileName;Integrated Security=True
or use the AttachDBFilename feature of the User Instances mode..

try modifying the connection string to see if you are granted connection to the instance you are dealing with, as the exception you are reporting is quite a generic connection exception..

regards

|||

Andrea

I still have the same problem, I have updated my connection string to this:

Data Source = .\SQLEXPRESS;AttachDBFilename = [DataDirectory]\PLDaq.mdf;Integrated Security = True; UserInstance = False

I have managed to get arround the error by changeing the name of the non-design computer to mach the name of the design computer, this however, as I am sure you will agree, is only temporary as I don't want to have to change the name of every computer that I install this application on, what do I need to do to rectify this situation.

|||

hi,

as you are not using "User Instances", I'd not go for the AttachDBFileName property of the connection string.. I'd attach/create the database once and then I'd go for the "traditional" Database=yourDbName property of the connection string...

I have managed to get arround the error by changeing the name of the non-design computer to mach the name of the design computer

do you mean by that you "named" the destination computer the same as your dev pc? this is obviously not "mandatory"...

what is your |DataDirectory| value?

regards

|||

do you mean by that you "named" the destination computer the same as your dev pc? this is obviously not "mandatory"...

Unfortunatly this is the only way it will not generate the error posted above. Like I said the program is looking for a remote connection but I want a local one. So I tricked it into thinking that it was running on the dev computer by changeing the name. I will agree that this is obviously not convient, but that is why I am posting I just cant figure out how to fix it.

The |DataDirectory| tells the connection to look in the bin\debug folder during dev time, and also to look into the bin\data folder at run time, after installation obviously. So when the program is installed and all data files are stored in the (AppPath)\bin\data directory and that is where the program is supposed to look for the data files (e.g. Database and Log files), however, if the non dev computer has a different name it trys to find the dev computer to connect to the database, a remote connection, It cant do this as it is not connected to any network.

I have tryed the traditional Database = yourDbName and that causes the same problem

Also There may come a time when I want to use User Instances, but for the time being I just want the thing to work.

|||

PEng1 wrote:

Unfortunatly this is the only way it will not generate the error posted above. Like I said the program is looking for a remote connection but I want a local one. So I tricked it into thinking that it was running on the dev computer by changeing the name. I will agree that this is obviously not convient, but that is why I am posting I just cant figure out how to fix it.

the fix is using

Data Source = .\SQLEXPRESS or Data Source = (Local)\SQLEXPRESS property in the connection string...

here you have to specify the instance you have to connect to, and you can provide "." and/or "(Local)" for "local" connections"...

The |DataDirectory| tells the connection to look in the bin\debug folder during dev time, and also to look into the bin\data folder at run time, after installation obviously. So when the program is installed and all data files are stored in the (AppPath)\bin\data directory and that is where the program is supposed to look for the data files (e.g. Database and Log files), however, if the non dev computer has a different name it trys to find the dev computer to connect to the database, a remote connection, It cant do this as it is not connected to any network.

pay attention to your "custom data folder"... consider that the account running the SQLExpress intstance required adeguate NTFS permissions to that folder.. and consider Vista "headaches"/requirements with regard writing in Program Files folder...

regards

|||

Andrea,

I guess that I had the answer for a while and just didn't bother to check if it would work with a different name, or I changed something and just don't remeber what, probably the latter of the two, either way, the problem is resolved and I am greatly indebted for all of your help. Thanks a lot.

This program will be run on Windows 2000 for quite a while but it will eventually have to be moved to Vista or higher, what "headaches" are you refering to, I am not at all familiar with Vista since the company I work for still has some machines that are running 95 and One that is running DOS, yeah thats right I said DOS. I guess however that I should probably read up on the New OS any recomended reading?

|||

hi,

PEng1 wrote:

Andrea,

I guess that I had the answer for a while and just didn't bother to check if it would work with a different name, or I changed something and just don't remeber what, probably the latter of the two, either way, the problem is resolved and I am greatly indebted for all of your help. Thanks a lot.

This program will be run on Windows 2000 for quite a while but it will eventually have to be moved to Vista or higher, what "headaches" are you refering to, I am not at all familiar with Vista since the company I work for still has some machines that are running 95 and One that is running DOS, yeah thats right I said DOS. I guess however that I should probably read up on the New OS any recomended reading?

start reading at http://technet.microsoft.com/en-us/windowsvista/aa905108.aspx, http://technet.microsoft.com/en-us/windowsvista/aa906021.aspx, ....

and look in this forum for Vista troubles with UAC..

regards

Sunday, March 11, 2012

connecting to database error

Hi there

i have a problem connecting creating a data source to SQL server express.

I am running winXP with service pack2

My machine is APOLLO\SQLEXPRESS

i AM USING AN ODBC CONNECTION.

i GET THE FOLLOWING ERRORS:

SQL SERVER ERROR 1231

AND

SQL SERVER ERROR 17.

Having done a google search and looked at the local security settings i am not sure what to add to the object names.

Can anybody please help.Gino

Gino,

You need to add authentication to your connection string. An application has it's own identity that SQL Server will not recognize.

Adamus

|||

Hi there again

Could you please state step by step procedure to perform this authentication. Is this authentication code based or windows based as i have mentioned previously? If this is code based could you please give some hints.

Gino