Shaitan00 Posted February 8, 2005 Posted February 8, 2005 I am writing an ASP.NET web application that has to interface with an SQL Database (SQL Desktop Server, the one that comes with Visual Studios.NET 2003) When I try to perform a SELECT on my DB I get the following error: Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied. Line 54: sqlDA.Fill(ds); I was thinking it was probably my Connection String that was incorrect (I use very similar code in Windows Applications at work and it it okay so only different factor is my localhost SQL Desktop Server) and I am currently logged on as admin on my XP-SP2 box This is what I am currently using: string strConnection = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Term;Data Source=(localhost);Packet Size=4096;Workstation ID=MYPC" Where [TERM] is the name of the TABLE and MYPC is my computers machine name. C# CODE: string strQuery = "Select * from [Term]"; m_SqlConnection = new SqlConnection(); m_SqlConnection.ConnectionString = strConnection; M_SqlConnection.Open(); System.Data.SqlClient.SqlDataAdapter sqlDA = new System.Data.SqlClient.SqlDataAdapter(strQuery, m_SqlConnection); System.Data.DataSet ds = new System.Data.DataSet(); sqlDA.Fill(ds); Is this incorrect? Is there a way to test the database connection manually (can't debug in ASP.NET)? Can oSQL help to troubleshoot? Am I going about this the wrong way for Web applications? (difference with normal Windows applications?) Any help would be appreciated. Thanks, Quote
Administrators PlausiblyDamp Posted February 8, 2005 Administrators Posted February 8, 2005 In your connection string the Initial Catalog=Term is probably wrong, rather than the table name replace Term with the Database name. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Shaitan00 Posted February 8, 2005 Author Posted February 8, 2005 Well I used oSQL to create my Table and it just added it to the "master" database. So I changed my connection string to: "ConnectionString" value="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=(localhost);Packet Size=4096;Workstation ID=MYPC" Get the exact same error...hummmm Quote
Administrators PlausiblyDamp Posted February 8, 2005 Administrators Posted February 8, 2005 You probably want to create your own database rather than just adding tables to master. Also the ASPNET account (the account asp.net web aaplications run under) will need to be given permissions to access the database in question. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Shaitan00 Posted February 9, 2005 Author Posted February 9, 2005 Mind if I ask how you create a new database (not to use master) using oSQL (SQL Desktop Server)? Currently all I did was something like: Create table Term (ID int identity primary key , Name varchar(30) unique not null , etc.... How can I create new Databases and then add tables to them in oSQL? This may explain my access issues? (I added username/password to the connection string [confirmed with oSQL they work] and still nothing.....) Quote
kleine Posted February 25, 2005 Posted February 25, 2005 Mind if I ask how you create a new database (not to use master) using oSQL (SQL Desktop Server)? Currently all I did was something like: Create table Term (ID int identity primary key , Name varchar(30) unique not null , etc.... How can I create new Databases and then add tables to them in oSQL? This may explain my access issues? (I added username/password to the connection string [confirmed with oSQL they work] and still nothing.....) Sollution: CREATE DATABASE database_name [ ON [ < filespec > [ ,...n ] ] [ , < filegroup > [ ,...n ] ] ] [ LOG ON { < filespec > [ ,...n ] } ] [ COLLATE collation_name ] [ FOR LOAD | FOR ATTACH ] < filespec > ::= [ PRIMARY ] ( [ NAME = logical_file_name , ] FILENAME = 'os_file_name' [ , SIZE = size ] [ , MAXSIZE = { max_size | UNLIMITED } ] [ , FILEGROWTH = growth_increment ] ) [ ,...n ] < filegroup > ::= FILEGROUP filegroup_name < filespec > [ ,...n ] Example given: USE master GO CREATE DATABASE Sales ON ( NAME = Sales_dat, FILENAME = 'c:\program files\microsoft sql server\mssql\data\saledat.mdf', SIZE = 10, MAXSIZE = 50, FILEGROWTH = 5 ) LOG ON ( NAME = 'Sales_log', FILENAME = 'c:\program files\microsoft sql server\mssql\data\salelog.ldf', SIZE = 5MB, MAXSIZE = 25MB, FILEGROWTH = 5MB ) GO Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.