Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
knight07
Starting Member
17 Posts |
Posted - 2008-04-30 : 01:57:18
|
Hello guys..I'm new to sql server and have been trying to connect to my database through vb.net code with a connection string held in an xml file, but it is not working. I get this folloing message: quote: cannot open database: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\SQLBookEvaluation.mdf requested by the login. The login failed. Login failed for user 'KNIGHT07\Mousa
I tried other databases that come with sql server 2005 express (by typing the database in the connection string and it works.This is the connection string:<?xml version="1.0" encoding="utf-8" ?><Connection> data source=localhost\sqlexpress;initial catalog= dbSQLBookEvaluation;Integrated Security=True;</Connection> and this the code that reads the connection string:Imports System.Data.SqlClient Imports System.Xml Public Class ConnectBookEvalSQL ' Dim bookEvalConString As String ' Dim conBookEvaluation As New SqlClient.SqlConnection Public Shared Function GetConnection() As SqlConnection Return New SqlConnection(GetConnectionString) End Function Private Shared Function GetConnectionString() As String Dim xmlReader As New XmlTextReader("csSQLBookEvaluation.xml") Return xmlReader.ReadElementString("Connection") End Function End Class Note that I created my database using sql server 2005 express edition (management studio) and I made some test data and it works fine.After trying many things, I believe that it is sothing that I'm missing in the database;such as a security setting.Anyone have any clue.Any help would be appreciated.Thanx million |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-30 : 12:57:17
|
| Have you added KNIGHT07\Mousa to SQL Server?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
knight07
Starting Member
17 Posts |
Posted - 2008-05-01 : 01:39:34
|
| Hello Tara..and thnx for you reply.As I mentioned in my first post, I'm new to The SQL server. But as far as I understand "KNIGHT07\Mousa" is added. I know this Simply because, when I run the studio manager and open the "logins" under security folder, I find there. Is this what you mean?If not, please tell how to add it, or may be alter it so that Im able to connect through it..Thanx again Tara |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-05-03 : 21:05:40
|
| That doesn't mean you added it as sql login, have to logon to sql server and create sql login for that windows account. Sql books online tells you how to do it. |
 |
|
|
|
|
|