473,386 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C# and SQLDMO

T.
I dumped VB and adopted C# for this version of Visual Studio. My problem! I
am trying to reference an SQLDMO.Database object in C# like so:

private SQLDMO.Database dbcurrent;
private string dbname;

dbname = "Northwind";
dbcurrent = (SQLDMO.Database)sqlsvr.Databases.Item(dbname);

But I get this error : No overload for method 'Item' takes '1' arguments.

I was hoping to avoid iterating through the SQLDMO.Databases collection to
obtain the ID of the database I want, and reference my target database via
that ID.
e.g. dbcurrent = (SQLDMO.Database)sqlsvr.Databases.ItemByID(i);

Any suggestions? And thanks in advance
Nov 16 '05 #1
3 5277
Are you looking for something like this

string dbName = "Northwind";

SQLDMO.Database db = new SQLDMO.Database();

SQLDMO.SQLServer srv = new SQLDMO.SQLServer();
srv.Name = "(local)";

srv.LoginSecure = true;

srv.Connect(null,null,null);

db = (SQLDMO.Database)srv.Databases.Item(dbName,null);

MessageBox.Show("I have in my hand this database - " + db.Name + " it is
this big " + db.Size.ToString());

srv.DisConnect();


--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know
"T." <T@discussions.microsoft.com> wrote in message
news:6A**********************************@microsof t.com...
I dumped VB and adopted C# for this version of Visual Studio. My problem! I am trying to reference an SQLDMO.Database object in C# like so:

private SQLDMO.Database dbcurrent;
private string dbname;

dbname = "Northwind";
dbcurrent = (SQLDMO.Database)sqlsvr.Databases.Item(dbname);

But I get this error : No overload for method 'Item' takes '1' arguments.

I was hoping to avoid iterating through the SQLDMO.Databases collection to
obtain the ID of the database I want, and reference my target database via
that ID.
e.g. dbcurrent = (SQLDMO.Database)sqlsvr.Databases.ItemByID(i);

Any suggestions? And thanks in advance

Nov 16 '05 #2
T.
Many thanks Allan.

Basicall this is what I was looking for :
(SQLDMO.Database)srv.Databases.Item(dbName,null); the null parameter to the
Item method.
"Allan Mitchell" wrote:
Are you looking for something like this

string dbName = "Northwind";

SQLDMO.Database db = new SQLDMO.Database();

SQLDMO.SQLServer srv = new SQLDMO.SQLServer();
srv.Name = "(local)";

srv.LoginSecure = true;

srv.Connect(null,null,null);

db = (SQLDMO.Database)srv.Databases.Item(dbName,null);

MessageBox.Show("I have in my hand this database - " + db.Name + " it is
this big " + db.Size.ToString());

srv.DisConnect();


--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know
"T." <T@discussions.microsoft.com> wrote in message
news:6A**********************************@microsof t.com...
I dumped VB and adopted C# for this version of Visual Studio. My problem!

I
am trying to reference an SQLDMO.Database object in C# like so:

private SQLDMO.Database dbcurrent;
private string dbname;

dbname = "Northwind";
dbcurrent = (SQLDMO.Database)sqlsvr.Databases.Item(dbname);

But I get this error : No overload for method 'Item' takes '1' arguments.

I was hoping to avoid iterating through the SQLDMO.Databases collection to
obtain the ID of the database I want, and reference my target database via
that ID.
e.g. dbcurrent = (SQLDMO.Database)sqlsvr.Databases.ItemByID(i);

Any suggestions? And thanks in advance


Nov 16 '05 #3
I dumped VB and adopted C#


Good for you.
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ewm | last post by:
Using InstallShield Developer 7.04. Does anyone know of a good way to detect if SQLDMO is installed? TIA mcpoo
1
by: Mohammed Abdel-Razzak | last post by:
Dear sirs I`ve used SQLDMO to make a backup to my database How can I use it to restore database? thanks Mohammed
1
by: C# beginner | last post by:
Hi all, I am using SQLDMO.Backup for backing up SQL server databases. I need to implement a progress bar to show the progress. I have some sample VB code that is like this: Dim WithEvents...
1
by: | last post by:
Hi all My requirement is to "on button_click, backup a SQL database using SQLDMO.Backup object and update the progress in a ProgressBar. The problem is the progress bar does not update at all...
2
by: | last post by:
Hi all, continued from yesterday's posting... I still haven't found a solution to this issue. I put a breakpoint in private void SqlBackupPercentComplete(string message, int Percent) {...
1
by: | last post by:
Hi all I am posting this to check if anyone could help me. The problem still persists. I am beginner in C#. Thanks. Subject: SQLDMO.Backup and ProgressBar - help please From: ...
0
by: Craig G | last post by:
i have a small application that uses the SQLDMO com object when i build a setup package to distribute it adds both the Interop.SQLDMO.dll assembly & sqldmo.dll File the problem is that the...
6
by: Craig G | last post by:
how the hell do i get this to register?!?!? my test pc is running XP & MDAC 2.8 but still it wont register SQLDMO.dll and is therefore preventing my application from running and i dont want...
3
by: Brian Henry | last post by:
Anyone know why this would happen... I added a reference to the SQLDMO COM object, imported it on top of my code.. then this test code fails Imports SQLDMO Module Module1 Sub Main() Dim...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.