Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
GeneralRe: Hashtable and dictionary Pin
PIEBALDconsult17-May-10 4:24
mvePIEBALDconsult17-May-10 4:24 
QuestionC# version Pin
sujithkumarsl16-May-10 20:53
sujithkumarsl16-May-10 20:53 
AnswerRe: C# version Pin
nagendrathecoder16-May-10 21:11
nagendrathecoder16-May-10 21:11 
AnswerRe: C# version Pin
Abhinav S16-May-10 21:40
Abhinav S16-May-10 21:40 
GeneralRe: C# version Pin
sujithkumarsl16-May-10 22:08
sujithkumarsl16-May-10 22:08 
QuestionDataSets and DataAdapters Pin
USAFHokie8016-May-10 17:09
USAFHokie8016-May-10 17:09 
AnswerRe: DataSets and DataAdapters Pin
USAFHokie8016-May-10 22:09
USAFHokie8016-May-10 22:09 
QuestionGetting Database Names from Server MS SQL 2005 Pin
PDTUM16-May-10 11:20
PDTUM16-May-10 11:20 
Good Afternoon,

I posted this in General Databases earlier, but am not sure if is instead a C# problem since I am actually writing an application, so I am posting it here as well.

I used a nice SQL insert/update program for years with MSSQL 2000, but was never able to get it past security to make it work with 2005. This weekend, out of frustration, I decided to take a shot at writing one of my own. In doing so, I attempted to list the databases that were on the server. I first tested the command in the Query analyzer and it worked fine, returning all the names of the databases. However, when I tried to use the exact same code in the application, every database name comes up as "master" in the array, so I cannot continue to propagate the tables without a named database. I cannot understand how the identical code can return different results in different places. Here is the code.
Appreciate your assistance....Thank you, Pat

string Sql = "SELECT name FROM sys.databases";

                SqlCommand Comm = new SqlCommand(Sql, Conn);

                SqlDataAdapter da = new SqlDataAdapter(Comm);
                DataSet ds = new DataSet();
                da.Fill(ds);
                
		int cnt = ds.Tables[0].Rows.Count;
                string[] dbs = new string[cnt];

                for(int i = 0; i < cnt; i++)
                {
                 dbs[i] = ds.Tables[0].Rows[0]["name"].ToString();   
                }
 
                foreach(string s in dbs)
                {
                    databases.Items.Add(s);
                }

AnswerRe: Getting Database Names from Server MS SQL 2005 Pin
Ravi Bhavnani16-May-10 13:25
professionalRavi Bhavnani16-May-10 13:25 
GeneralRe: Getting Database Names from Server MS SQL 2005 Pin
PDTUM16-May-10 15:14
PDTUM16-May-10 15:14 
AnswerRe: Getting Database Names from Server MS SQL 2005 Pin
Eddy Vluggen16-May-10 14:40
professionalEddy Vluggen16-May-10 14:40 
AnswerRe: Getting Database Names from Server MS SQL 2005 Pin
PDTUM16-May-10 15:07
PDTUM16-May-10 15:07 
GeneralRe: Getting Database Names from Server MS SQL 2005 Pin
Eddy Vluggen16-May-10 23:26
professionalEddy Vluggen16-May-10 23:26 
QuestionImage Annotation in C# Pin
snouto16-May-10 10:51
snouto16-May-10 10:51 
AnswerRe: Image Annotation in C# Pin
Pete O'Hanlon16-May-10 11:01
mvePete O'Hanlon16-May-10 11:01 
GeneralRe: Image Annotation in C# Pin
snouto16-May-10 11:52
snouto16-May-10 11:52 
GeneralRe: Image Annotation in C# Pin
Pete O'Hanlon16-May-10 21:37
mvePete O'Hanlon16-May-10 21:37 
AnswerRe: Image Annotation in C# Pin
Luc Pattyn16-May-10 11:43
sitebuilderLuc Pattyn16-May-10 11:43 
AnswerRe: Image Annotation in C# Pin
Ravi Bhavnani16-May-10 13:30
professionalRavi Bhavnani16-May-10 13:30 
QuestionPorting a Windows Forms project to Mono Pin
User 691845416-May-10 10:24
User 691845416-May-10 10:24 
AnswerRe: Porting a Windows Forms project to Mono Pin
OriginalGriff16-May-10 21:45
mveOriginalGriff16-May-10 21:45 
QuestionHaving problems with C# and OpenGL interoperability Pin
Keith Vitali16-May-10 9:04
Keith Vitali16-May-10 9:04 
AnswerRe: Having problems with C# and OpenGL interoperability Pin
Keith Vitali16-May-10 11:44
Keith Vitali16-May-10 11:44 
QuestionImplicit Variables Pin
Darrall16-May-10 6:51
Darrall16-May-10 6:51 
AnswerRe: Implicit Variables Pin
Abhinav S16-May-10 7:22
Abhinav S16-May-10 7:22 

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.