Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How To Get The List Of Names Of The Databases Of A Server Using OleDbConnection In C#.......?


I want to get the names of the databases of the server using OleDbConnection in c# which i have to add in to a combobox.....the same task i achieved using SqlConnection where in there is a Class SqlClientCollectionNames...the code is as follows
using (SqlConnection connection =new SqlConnection("Data Source=server;User ID=username;Password=passwd"))
 {
                connection.Open();
                DataTable myData = connection.GetSchema(SqlClientMetaDataCollectionNames.Databases);
                foreach (DataRow row in myData.Rows)
                   comboBox1.Items.Add(row[0]);
               connection.Close();
}  
 
but the same i did for OleDbConnection it is not working
 using (OleDbConnection connection =new OleDbConnection("Provider=SQLOLEDB;Data Source=server;User ID=username;Password=passwd"))

 {

                connection.Open();

                DataTable myData = connection.GetSchema(SqlClientMetaDataCollectionNames.Databases);//no such method Databases  present in OleDb namespace

               
                foreach (DataRow row in myData.Rows)

                   comboBox1.Items.Add(row[0]);

               connection.Close();


 
 
is there any other way to do this using OleDbConnection........??Please help 




View Complete Forum Thread with Replies

Related Forum Messages:
List The System Names Has Sql Server Installed
hi,I need to display the system names which has sql Server installed. How it can be done in vb.net. Help me plzregardsSomu

View Replies !
Getting List Of Databases From Server
 

Is there a way I can query the database server (SQL 2000) to get a list of all the available databases? As a threshold problem I am not clear how I would connect to the server. I am using VB.Net and presently connect to one database at a time. The connection string is in an XML file, such as:

<?xml version="1.0" encoding="utf-8" ?>

<Connection>workstation id=ASUS;packet size=4096;user id=sa;data source="5.15.183.222KWMSDE2"; persist security info=True;initial catalog=tsLocal;password=pass

</Connection>

Is there some special way that you connect to the server without specifying the database?

Is there a certain query I must use once I am connected? Can the information be returned in the form of a data table in a data set?

Thanks.

View Replies !
Want To Grab A List Of Available Databases On A Given Server
I have MSDE running on my system and I want to get a list of databasesfor that server programmatically. I'm using vb.net and I want to view,add, delete and modify databases on a server from within a class.I'm aware I can use the "Server Explorer" feature in Visual Studio, butthat isn't what I'm looking for. Any references or suggestions on whereto start are appreciated.TIARalf

View Replies !
Browse Through A List Of Databases On A Given Server
Hi,

I would like to allow the user of my ADO.NET application to browse through a list of the available databases on a given server. INFORMATION_SCHEMA in SQL Server Books Online doesn't describe how to do this. How can I do this?
TIA,
Royce

View Replies !
List Of Databases On An Instance Of SQL Server
Is there a way of limiting the "Databases list" to just the databases which I have permission to?
My databases is in a hosted environment, and the list of databases on that server is HUGE.

View Replies !
The List Databases And Tables In SQL SERVER With SQLDMO
hi
i have a project and i want make thats;
1-)The list All SQL Server(s) in my network to dropdrown list(that's ok)
2-) the list all databases to selected sqlserver(that's ok)
3-) the list tables to selected database(i cant)
 
i wrote my source kod please help me
 
1-)
Dim mDMOApp As New SQLDMO.Application
Dim mNames As SQLDMO.NameList
Dim t As Integer

mDMOApp = New SQLDMO.Application
mNames = mDMOApp.ListAvailableSQLServers()
lstServers.Items.Clear()

For t = 1 To mNames.Count
lstServers.Items.Add(mNames.Item(t))
Next
 
2-)
 
Dim server As New SQLDMO.SQLServer
Dim db As SQLDMO.Database

server.Connect(mysqlserver, "xxx", "xxx")
For Each db In server.Databases
lst.Items.Add(db.Name)

Next
3)
how can i ???
 

View Replies !
Oledbconnection In Vb.net 2005 And Sql Server Express Test Connection
Hey everyone,

I was had just finished creating the architecture for a test databse using sql express 2005 and have been able to get the browser and sql service started just fine. However, When I try to create an oledbconnection or oledbadapter to the database using the Microsoft SQL Server engines I get the following error: I have tried using a direct path to the database in the server name and the computer's name itself. Everything is on the local machine and I have not started remotely connecting. [DBNETLIB][ConnectionOpen (Connect()).] SQL Server does not exist or access denied. I am using windows authentication and have also specified the direct patht to the database in the attach database file:  Thanks for the help.

Shullaymahl

View Replies !
SQL To List Column Names
Can anyone help me with a SQL statement that will list all the column names in a table please ?

I just want to list out the column name so that i can develop asp/vb more effectively than having to use SQLEM and Design table to see the field names.:confused:

thanks
FatherJack

View Replies !
List Column Names Of Sql Table
I know it is basics, just slipped out of my mind, How do we list or print the columns names of table in sql server 2000.
thanks,
 

View Replies !
How To Get The List Of Table Names In A SQL2005 Database
How to get the list of table names in a SQL2005 database?

View Replies !
List Table Names In A Database Having A Particular Column.
Can anybody tell me how to find out whether a particular column exists in any of the tables of a database and if it does, display the table names?
 

Thanks

View Replies !
Create List Of Table Names And Size For A Database
Hi there,

I am trying to create a list of all the tables in one database and then list the size of each table. So for example I want to create a table with the table name and table size for one DB

E.g

Table1 1111KB
Table2 123300MB
Table3 120448KB

etc for all the tables in a particukar DB

I know there is a stored procedure to list the sizes: 'sp_spaceused' but not sure how to script all this together.

can anyone help please!!

From

NewToSQL

View Replies !
How To Get Names Of All Databases Using Sql Statements?
How can i get names of all databases using sql statements or system stored procedures? Thanks in advance!

View Replies !
Using Qualified Names Of Databases
I have databases a1 , a2 , a3 , a4 ... an.
Each has a table t1 .

I am writing a stored proc which compares the t1 table between any given two databases.
I want to pass the database name as a variable ..
so the SPROC looks like

exec sp_comparetable 'a3' , 'a7'

My question is , inside the SPROC ,how do I refer to the tables in the a3 and a7 databases.


Thanks,
Alok.

View Replies !
Move Files From Directory Based On Names On A Static List.
I have a scenario where I need to move a series of files from within a directory of many files. The files follow no nameing convention and are more of less random. However the file names never change from week to week. I tried various different options in a 'file system task', no go.
Any ideas on how to move only a list of files?

or

can I load only specific files into a 'Foreach Loop container' from a certain directory. I tried delimiting file names in the file source, that did not work.
 
Either way can work,
Thanks

View Replies !
GROUP BY Expressions Must Refer To Column Names That Appear In The Select List.
Hi,
 
Is there any way to group variables present in a select statement.
 
My code:
 
SELECT @var1=something, @var2=something_else
FROM ...
GROUP BY @var1
 
I wanted to group by 'something' hence I used a variable to assign it to. But I'm unable to group it.
 
Any thoughts?
 
Thanks,
Subha
 
 
 

 
 

View Replies !
Return All Databases Names Using Query?
Hi, I am trying to get all the databases from MS SQL into a dropdownlist. However, I am not sure how to do that in query ... is there a way to retrieve all databases name using  a query in MS SQL? Thanks.

View Replies !
How To Prevent Displaying All Names Of Databases?
I get an issue, that is: Once i expand databases from SQL Enterprise Manager, it takes a long time to wait displaying all names of databases. How should i do to prevent displaying all names of databases?

View Replies !
List Of Databases
Hi
How can I update databases that have been droped
or added.
my goal is to save changes that have been made
for a server.
thank you

View Replies !
For Each Across List Of Databases
I need to get records from multiple databases.

In my main database, I have a list of databases related to seperate business units.

For each of those databases, I need to get a list of values from a table (the table exists in each database).

Basically

foreach database in a list
    Do  a Lookup
end

Possible?

View Replies !
List Of Databases
hello anybody now

i need to find how many Databases in  my local SQL server (programatically).i know i have 8 databases is there but i need to print each and every database.

can anybody help me.

thanx

kiran.

 

View Replies !
Query A List Of Databases
anyone know how to query a list of databases?

current the sp_helpdb seems cant help me, because it query all the details, i want to do it like select * from database where database id=2

View Replies !
List Of Attached Databases
How can I, programatically, get a list of attached databases? I'm using VB.

View Replies !
List Attached Databases?
Is there a stored procedure to list attached databases?
You can do this:
use Master
exec sp_helpfile
go

Which shows you the config files for the current DB.
What if you want to do a multiple sp_detach_db? If you could get a list of the attached DB's you could recursilvely or conditioinaly detach.

View Replies !
List Databases With Their Size
I want to list my databases, and physical related files, and their size but the following commands do not provide the size. Any idea?

SELECT * FROM sysdatabases
SELECT * FROM sys.sysfiles


I know it's silly question

Canada DBA

View Replies !
Are Duplicate Instance Names A Problem If Physical Server Names Are Different?
If I restore the master database from ServerA to ServerB and start the SQL Server services on ServerA and ServerB, the master databases will be identical and running sp_helpserver and @@ServerName will indicate the SQL Server instance for both instances is ServerA.  Is this ok considering the physical server names are different? 
 
If this is ok, how does SQL Server advertise on the network who it is?  Does it append the physical server name to the SQL Server instance name during network communications?
 
Thanks,    Dave

View Replies !
List Of Databases In Analysis Services
Hi all,I have to write a program to read the names of databases in AnalysisServices. I don't know which table I can get this information from.Thanks a bunch

View Replies !
List Of Columns From Tables Across Databases.
Hey guys,Couldn't find this anywhere in google.I want a list of all database column names for a specific table/viewfrom across database.I tried this...-----------------------------------------------------Select *[color=blue]>From Information_Schema.Columns[/color]-----------------------------------------------------I also tried this...-----------------------------------------------------select syscolumns.name, sysobjects.name, * from syscolumns, sysobjectswheresysobjects.id = syscolumns.idand (sysobjects.xtype='U' or sysobjects.xtype='S')-----------------------------------------------------These queries return information about the CURRENT database.But, if I want to do it ACROSS database or across servers.. how can Ido this?I will express my gratitude to everyone who is kind enough to answerthis question. (I've been stuck with this problem for a while now.)Thanks!OhMyGaw!

View Replies !
List Of All Table Sizes In A Databases
Hi,

Is there a query I can run to retrieve a list of all tables and their sizes in a database? I want something that is like the feature in Enterprise Manager when you click on a database and then the 'Tables & Index' link. It lists the tables and their respective size. I want to push this into a spread sheet.

The reason why I am doing this is the compare data between 2 different databases. Since I cannot find a tool that will compare the data, the closest I can get (without bcp-ing out all data and comparing) is to look at the sizes of each table.

Thanks!
Joyce

View Replies !
List Of Databases From Multiple Servers Without SMO
 

Is it possible to get an aggregate list of databases from multiple servers, without using SMO?
 
All target servers are running SQL Server 2005.
 
Ben Aminnia

View Replies !
List All Databases That A User Has A Login
Hi everyone,
I have an instance with many databases in it. I am looking for the easiest way to see which of those databases a user has a login on. What is the most efficient way of doing this?
Thanks,
Anil

View Replies !
Display List Of Databases In App_Data Folder
Hi All,
The web site I'm working on will allow admin users to create a new database for each new client. I'm hoping to be able to keep all of the databases in the local App_Data folder, but I'm finding that I can't even find a way of generating a list of the databases in the App_Data folder.
The code I have is:Dim serverConn As New ServerConnection(".SQLEXPRESS")
serverConn.LoginSecure = True
serverConn.ConnectTimeout = 30
serverConn.Connect()
Dim sqlServer As Server = New Server(serverConn)

For Each db As Database In sqlServer.Databases
ListView1.Items.Add(db.Name)
NextThis does populate a list of databases, but not the ones in the App_Data folder - just those attached directly to the server.Any help on this will be greatly appreciated as it's starting to drive me nuts!Thanks,Paul

View Replies !
Howto: List Database Files From Databases?
Hi,

I'm trying to list all database locations with SQL command, but getting lost here :(

So, anyone any idea how to get databasefile locations from server?
All I need is like: 'C:Program FilesMicrosoft SQL ServerMSSQLDatamaster.mdf' and others.

Thanks.

View Replies !
How Can Hide List Of Databases When Client Connects To...
Hi all,
Now, I using Windows200o & SQL7.0.
I want to permission a client connect to my server,
and with his login, he only works with a specify datatbase.
When he connects to my server, although he can't work other databases,
but he can list of them in server - using EM (and I don't want he knows this).
How can I solve this problem? Thanks.

View Replies !
OleDbConnection With MSDE
I'm trying to connect to a MSDE database using the following code:


'set up connection
dim myConnection as new OleDbConnection("Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=LearnASP_DB;Integrated Security=SSPI;Connect Timeout=30")

'open connection
dim myCommand as new OleDbDataAdapter("select * from tblUsers",myConnection)

'fill dataset
dim ds as DataSet = new DataSet()
myCommand.Fill(ds, "tblUsers")



And I'm getting the following error:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

Can someone tell me what I'm doing wrong?

Thanks in advance

View Replies !
OleDbConnection Vs SqlConnection
Hi,

How much of a performance difference is there between connecting to SQL Server 2000 using OleDbConnection or using SqlConnection?

The reason I'm asking is I am taking on the task of updating an older program that uses a Access Database to use SQL Server, but it has a Database Utility class that uses OleDbConnection. I'm just debating whether it would be worthwhile to upgrade the class to use the SQL objects rather than Oledb. Program does a lot of update and insert of invidual records, and a few select statements that usually return from 1 to 2000 records up to a maximum of 50,000 records

Thanks

View Replies !
Get List Of All The Databases Hooked Up To A Specific Login Name Created
Hi

 

I have created a new login in SQL Server 2000.

I have hooked up to more than one database which creating the login.

 

In syslogins we can see only the default database associated with that login.

 

I want the list of all the databases for that specific login..

 

How could I get them?

-------------------------------------------------------------------------------

My main task is to create a login under a specific database.

For which I'm validating whether that login already exists or not I'm checking it in the syslogins table. I need to specifically check it is in my databse or not....for that what should I do...

 

Thanks in advance

View Replies !
SQLConnection && OleDbConnection Problem
Hi, I want to create a connection to a SQL Server with SQLConnection. When I setup the SqlConnection through the Properties and Test Connection, everything seems to be good. However when I run the code sqlconnection1.Open(), it will give me the error of "Server does not exist or access denied".
I have tried with the OleDbConnection (SQL Server and Access) too, still had not luck. Anyone had any idea what's wrong? Thanks.

Please note that I tried the ADOBE.Connection (VB 6) to the same SQL Server and Access through ODBC and it didn't give me any problem.

I am running Win2000 Pro and have both Visual Studio 6 and Visual Studio.Net installed

View Replies !
DB Mirroring: Different Server Names With Same Instance Names
I'm going to be setting up DB mirroring between two SQL Server 2005 boxes. Since these are on two different servers, can the instance names be the same? Is there any reason NOT to do so if the mirror server is going to be used exclusively for DB mirroring?
 
For example: if the my primary DB is located on SERVER1INSTANCE1, can the mirror be SERVER2INSTANCE1 or do the instance names have to be different even though they're on different boxes.
 
Thanks!

View Replies !
Simple Question; Is There A Way To Geneteate A List Of Databases, Jobs, DTS Packages
I need to generate a list of databases, jobs, DTS packages, Linked servers, and users.
Is there a simple script or procedure for this?

Thanks

View Replies !
SqlConnection Doesn't Work While OleDbConnection Does
I've just installed SQL Server 2000 on a new machine, and fail to connect it using SqlConnection, the error message is "Database does not exist or access denied".
But I can connect it with a OleDbConnection without any problem. The connection string for that SqlConnection works perfectly with my old machine.
Could anyone give some advice? Thanks in advance.

View Replies !
SSIS Loading DWH Staging Area When Table Names Is Selected From Table List
Hello,
Maybe anyone have done that before?
I have table where i store SOURCE_TABLE_NAME and DESTINATION_TABLE_NAME, there is about 120+ tables.
i need make SSIS package which selects SOURCE_TABLE_NAME from source ole db, and loads it to DESTINATION_TABLE_NAME in destination ole db.
 
I made such SSIS package. set ole db source data access mode to table or view name variable.
set ole db destination data access mode to table or view name variable. set to variables defoult values (names of existing tables)
but when i loop table names is changed, it reports error, that can map columns, becouse in new tables is different columns.
 
how to solve that problem?
 
 

View Replies !
How Can I Get All Server Names And Catalogs Names For Specific Server
 

hii all,can any one help me to get this information.
 
i am using sql server 2000 and i want to know:
 
1- all names of servers
 
2- all database names (catalogs) at specific server and only which the user created . 
 
3- user name and password for each server.
 
 
thanks.

View Replies !
Server Names Or Instance Names
Hello there.  I'm trying to populate a drop down box with a list of all available instances of SQL server (express or not) available on a network.  To list all instances I'm using EnumAvailableServers() in SmoApplication. 

The issue is that the Instance column in the returned data table is always empty, and both the Name and the Server columns contain the same string -- the name of the computer the SQL server is installed.  Locally I have SSE installed, the instance name is <computer_name>SQLEXPRESS, however, using Smo I can't seem to get to the either full instance name or just the instance name.  I can't assume SQLEXPRESS, since there may be more than one installed. 

Alternately I used EnumRegisteredServers() in SmoApplication.SqlServerRegistrations and that, while returning instance information (can be retrieved from the RegisteredServer in the returned collection), doesn't always return the remote SQL servers in the list. 

Any idea how can this be done?  Maybe I'm going at it the wrong way, maybe there's another class / method I need to use to retrieve all instances? 

Thank you

View Replies !
Using Password Ending In Unmatched Double Quote Mark With OleDbConnection
 
Issue
 


I need to write VS2005 C# code using SQL OLE DB to access SQL Server 2005. I have no choice in that matter. I can create a database user with a password like COMPANY", which is a string of uppercase characters ending in an unmatched double-quote mark.
 
Using Microsoft SQL Server Server Management Studio I login using Windows Authentication, create an account with the password, COMPANY", check the "Enforce password policy", click "OK", and then exit.

 
Setup
 

I launch Microsoft SQL Server Server Management Studio again, select "SQL Server Authentication", type in the account name and the COMPANY" password, click the Connect button, and I'm in.
 
Problem
 

Now, I need to connect programmatically and run a stored procedure. The password is stored in clear text in hte Registry€”not my choice, it's a legacy application, and changing that is not an option open to me. (We have probably all seen company safes where the combination is scribbled on the wall in case you forget it!)
 
Here is the code I use to run the sproc:
 

DBCONNINFOLib.DBConnectionInfoClass DBConnInfo1 = new DBCONNINFOLib.DBConnectionInfoClass();
String strConnString = DBConnInfo1.GetConnectionString( "" );
OleDbConnection con1 = new OleDbConnection( strConnString );
OleDbCommand cmd1 = con1.CreateCommand();
cmd1.CommandType = CommandType.StoredProcedure;
String sCmdText = "sp_SomeStoredProcedure";
cmd1.CommandText = sCmdText;
 
If I set the connection string in the registry to COMPANY", I get an error like this:
 

Server Error in '/' Application.


Response is not available in this context.
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.Web.HttpException: Response is not available in this context.

Source Error:





Line 60: catch (System.Exception e)
Line 61: {
Line 62: Response.Write(e.Message.ToString());
Line 63: }
Line 64:
Source File: C:sourceProductNameDataCenterAdm&ReportsWebPagesProductNameWebCommonCodeCommon.cs    Line: 62

Stack Trace:





[HttpException (0x80004005): Response is not available in this context.]
System.Web.UI.Page.get_Response() +2077605
SiteIQWeb.CommonCode.Common..ctor() in C:ProductNameDataCenterAdm&ReportsWebPagesProductNameWebCommonCodeCommon.cs:62
SiteIQWeb.MasterPage..ctor() in C:ProductNameDataCenterAdm&ReportsWebPagesProductNameWebMasterPage.master.cs:21
ASP.masterpage_master..ctor() in c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files
oot255b545c8a400c7App_Web_hfj8popy.0.cs:0
__ASP.FastObjectFactory_app_web_hfj8popy.Create_ASP_masterpage_master() in c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files
oot255b545c8a400c7App_Web_hfj8popy.3.cs:0
System.Web.Compilation.BuildResultCompiledType.CreateInstance() +49
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +250
System.Web.UI.Page.get_Master() +48
System.Web.UI.Page.ApplyMasterPage() +18
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +685




Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

 
The closes to success I have been able to come is to set the password to "COMPANYNAME""" or 'COMPANYNAME"', which results in a System.Data.OleDb.OleDbConection Exception with a HResult of 0x80040e4d, and the message Login failed for user 'username'.

 
Questions
 

Can the password be formatted differently in the registry, or somehow processed after retrieving it, so that SQL Server 2005 will accept it?
 
Is this a bug in .NET Framework or SQL OleDb?
 
Is this simply a case of "Is it hurts, don't do it"?
 
Thanks in advance. As with all postings, my job, promotion, product success, company future, or some combination thereof is on the line.
 

View Replies !
If You Can Export List Of Users In Server Could You Import This List
Hello everybody.
Sql server has option to export list of users from Sql server to text file
Could we use this file to import users to specific database using T-Sql or
Enterprise Manager ?

Thanks

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved