Click here to Skip to main content
15,908,842 members
Home / Discussions / Database
   

Database

 
Questionxml in sql 2005 Pin
WhiteGirl235-Oct-10 21:39
WhiteGirl235-Oct-10 21:39 
QuestionA very Good artical on Query optimization techniques SQL server database Pin
ptr_Electron5-Oct-10 19:16
ptr_Electron5-Oct-10 19:16 
AnswerRe: A very Good artical on Query optimization techniques SQL server database Pin
Blue_Boy5-Oct-10 21:24
Blue_Boy5-Oct-10 21:24 
AnswerRe: A very Good artical on Query optimization techniques SQL server database Pin
David Mujica6-Oct-10 3:31
David Mujica6-Oct-10 3:31 
AnswerRe: A very Good artical on Query optimization techniques SQL server database Pin
Luc Pattyn6-Oct-10 3:41
sitebuilderLuc Pattyn6-Oct-10 3:41 
GeneralRe: A very Good artical on Query optimization techniques SQL server database Pin
ptr_Electron6-Oct-10 3:53
ptr_Electron6-Oct-10 3:53 
GeneralRe: A very Good artical on Query optimization techniques SQL server database Pin
Luc Pattyn6-Oct-10 3:55
sitebuilderLuc Pattyn6-Oct-10 3:55 
Question"Invalid object name" SqlException Pin
patzerFish5-Oct-10 16:02
patzerFish5-Oct-10 16:02 
Here's what I'm trying to do, using C#:

1 - Connect to SQL Server
2 - Check if a database is present.
3 - Create the database if it isn't.
4 - Create a login/user pair for that database.
5 - Store the connection string for future use.

I have this done, confirmed by using SQL Server Management Studio Express.

The following method throws an SqlException:

private static SqlDataReader executeQuery(String query) {
    SqlCommand command = new SqlCommand(query, Connection);
    SqlDataReader reader;
    try {
        openConnection();
        reader = command.ExecuteReader();
        return reader;
    } catch {
        throw;
    } finally {
        //connection left open because the reader is worked on elsewhere.
    }
}


The query: SELECT ReportGroupName FROM dbo.ReportGroups
The error message: Invalid object name 'dbo.ReportGroups'.
The offending line of code: reader = command.ExecuteReader();

Some lines from the script I used to create the database, tables and user:
CREATE LOGIN [bim] WITH PASSWORD=N'*******', DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
EXEC sys.sp_addsrvrolemember @loginame = N'bim', @rolename = N'dbcreator'
CREATE USER [bim] FOR LOGIN [bim] WITH DEFAULT_SCHEMA=[dbo]
CREATE TABLE [dbo].[ReportGroups]


I have a feeling that the problem lies with how I setup the default user, since I'm still learning databases, and it's been pretty hit or miss. However, the application worked previously using the above method with the same query string - the exception has only occurred recently, after creating the database from a script rather than in using the visual editors in SQL Server Management Studio. The script I used to create the database was derived from exports of the original database and tables, with only modifications made to create a login and a user.

Any assistance on tracking down how to fix this error would be greatly appreciated.
AnswerRe: "Invalid object name" SqlException Pin
patzerFish5-Oct-10 16:27
patzerFish5-Oct-10 16:27 
QuestionGrouped ordered precise select statement? Pin
Emmet_Brown5-Oct-10 2:45
Emmet_Brown5-Oct-10 2:45 
AnswerRe: Grouped ordered precise select statement? Pin
Emmet_Brown5-Oct-10 3:24
Emmet_Brown5-Oct-10 3:24 
AnswerRe: Grouped ordered precise select statement? Pin
Luc Pattyn5-Oct-10 3:30
sitebuilderLuc Pattyn5-Oct-10 3:30 
GeneralRe: Grouped ordered precise select statement? Pin
Emmet_Brown5-Oct-10 3:32
Emmet_Brown5-Oct-10 3:32 
GeneralRe: Grouped ordered precise select statement? Pin
Emmet_Brown5-Oct-10 3:34
Emmet_Brown5-Oct-10 3:34 
AnswerRe: Grouped ordered precise select statement? Pin
Emmet_Brown5-Oct-10 3:37
Emmet_Brown5-Oct-10 3:37 
GeneralRe: Grouped ordered precise select statement? Pin
Luc Pattyn5-Oct-10 3:42
sitebuilderLuc Pattyn5-Oct-10 3:42 
AnswerRe: Grouped ordered precise select statement? Pin
Mycroft Holmes5-Oct-10 13:06
professionalMycroft Holmes5-Oct-10 13:06 
AnswerRe: Grouped ordered precise select statement? Pin
Blue_Boy5-Oct-10 21:21
Blue_Boy5-Oct-10 21:21 
QuestionUsing OPENXML in stored Procedure Pin
meeram3955-Oct-10 1:26
meeram3955-Oct-10 1:26 
AnswerRe: Using OPENXML in stored Procedure Pin
Goutam Patra5-Oct-10 2:38
professionalGoutam Patra5-Oct-10 2:38 
QuestionNumber of Records [modified] Pin
T.RATHA KRISHNAN5-Oct-10 1:15
T.RATHA KRISHNAN5-Oct-10 1:15 
AnswerRe: Number of Records Pin
NeverHeardOfMe5-Oct-10 1:26
NeverHeardOfMe5-Oct-10 1:26 
GeneralRe: Number of Records Pin
T.RATHA KRISHNAN5-Oct-10 1:48
T.RATHA KRISHNAN5-Oct-10 1:48 
GeneralRe: Number of Records Pin
NeverHeardOfMe5-Oct-10 1:52
NeverHeardOfMe5-Oct-10 1:52 
GeneralRe: Number of Records Pin
T.RATHA KRISHNAN5-Oct-10 2:04
T.RATHA KRISHNAN5-Oct-10 2:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.