|
Hi again
I want to drop multiple tables from my database starting with the same name.
I've tried this:
SQLcommand = "DROP TABLE WHERE TABLE LIKE = 'a" + identity + "%'";
SqlCeCommand sucuk = new SqlCeCommand(SQLcommand, conn);
sucuk.ExecuteNonQuery();
but it didn't work
My tables start with an "a", and follows by an identity number, then a "year"
I want to drop all the tables with the same identity, what can be the suitable solution can anybody help me please ?
|
|
|
|
|
Hi,
why don't you look it up in the documentation? just type SQL and the keywords into Google.
e.g. DROP TABLE in SQL[^], as you can see there is no WHERE clause.
However in MySQL one can do "SHOW TABLES LIKE 'a%'"
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
ahah yeah you're right I've tried it and a few guys like me tried this WHERE clause
I couldn't find a proper syntax for C# to drop multiple tables
How can I use this "SHOW" ?
|
|
|
|
|
Emmet_Brown wrote: I couldn't find a proper syntax for C# to drop multiple tables
There is no direct relation to C#, whatever programming language you choose, in the end you are sending strings of SQL commands.
Emmet_Brown wrote: How can I use this "SHOW" ?
I have already told you its all in the documentation, i.e. one Google search away.
I suggest you get your act together.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
You can query sysobjects to find out which tables match your pattern. Then you have to issue a DROP TABLE command for each of them.
As pointed out, this belongs more to the Database forum.
Cheers,
Vikram. (Cracked not one CCC, but two!)
|
|
|
|
|
Take it to the General Database forum.
|
|
|
|
|
Query the sys.objects (or sysobjects in older versions of SQL Server) to find out the list of tables you want to delete, loop over them, construct DROP TABLE XXX commands dynamically and execute them with the EXEC command.
|
|
|
|
|
hi all
For my Console application in C# I would like to divide the main window area in 2 parts.
#1 for the message to be printed out during application lifetime
#2 for a menu where at least write some command or key to be pressed while the program is running.
How can be sure that one of my for-loop for example writes only in the #1 area without taking too much care of cursor position? Is it possible to define multiple areas of the screen as separate buffers where each text can be written or Console.WriteLine can be called?
Thanks
Mn
|
|
|
|
|
The only way I know to do this, is to store the details of your two parts, and render the whole screen again every time something changes.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
This is not going to be that easy with .NET. I used to work on such things long ago using FoxPro
|
|
|
|
|
The scenario: Peer-to-peer network through a switch; no DNS, all fixed addresses. Main app establishes a remoting connection (Activator.GetObject) to a marshalled singleton object in a service on another machine. The app reads properties and invokes methods on the remote object. It also subscribes, through a wrapper, to events raised by the remote object. Remoting is configured in the config file on both ends.
What works: All actions initiated by the app. Also, by monitoring the periodic events from the remote object, the app detects loss of connection (whether from physical disconnect or termination of the remote object) and will automatically recover when the object again becomes available. This has been extensively exercised.
What fails: If the app's host machine is not physically connected to the switch until after the app starts, the event subscriptions fail to work. The app gets no notice of this. The remote object gets a "connection actively refused" exception when it invokes the event delegate.
Already tried: Delaying instantiation of the event wrapper until after the first time the remote host could be successfully pinged. No change.
Please note: EVERYTHING works great as long as the network cable was connected at the time the app was started. All events are properly delivered and all subsequent disconnects are appropriately handled with successful recovery upon reconnect. The only known difference between the working and non-working scenarios is WHEN the network cable was connected to the switch: before or after the app starts.
I'm at a loss for where to look next. What am I missing? (Also, should I cross-post this to the .NET Framework forum?)
|
|
|
|
|
Hi
I create a windows form control library and use it in my forms;
I want to transfer a variable from my component to my code in form;
How can i do it?
|
|
|
|
|
This is a pretty basic question. How did you create a form control library ?
You can expose values as properties and read them in your form. Or you can expose a delegate that fires when a value is changed.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I crete form control library like other !
Is it a hard job?!
|
|
|
|
|
farokhian wrote: Is it a hard job?!
It requires you to write a line or two of code. If you don't know how to create a property ( let alone a delegate ), then I would suggest you buy a basic C# book and read it. I assume this is for a class, or you are teaching yourself. You can't possibly be a paid programmer ? Just buy a book and work through it, don't worry about class libraries if you don't even know basic C#.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I am teaching my self;
And i create properties and my problem was solved.
I don't think these things are so hard to learn ?!
This is the simple property that i create :
public string TxtBoxId
{
get
{
return text;
}
set
{
text = value;
}
}
Anyway THX.
|
|
|
|
|
Yes, that's all you need. What I am trying to say is, if you want to learn, buy a book to learn these sort of basics, otherwise there will always be holes in what you know, in terms of the fundamentals.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks alot for your suggestion .
Be sure that i do your suggetion.
Good Luck
|
|
|
|
|
I hope so. I've urged you to buy a basic book before, and you plainly have not done it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
can anyone help?
I tried to google out the solution but none of the answers I found was non proper for C#.
I've a MS SQL Database (Compact Edition(this is not an issue here))
I want to check if a table exists, what should I do?
I found an SQL statement for this
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TableName]') AND type in (N'U'))
but I could not figure out how to use this in C#
My first idea is=
string command2 = "IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TableName]') AND type in (N'U'))"
SqlCeCommand com2 = new SqlCeCommand(command2, conn);
Where should I look if it returned 1 or 0?
|
|
|
|
|
SQLCe will not support [dbo]. at the head of a table name. I don't know if it supports this sort of call ( I've never tried it ). Remove the [dbo]. and then complete the statement ( such as if EXISTS... select 1 ELSE select 0 ) then you can execute scalar and see if you get 1 or 0 back. You can experiment inside SQL Server management console to establish exactly what SQL works.
Your alternative is to say select * from tablename and do it in a try catch to see if it blows up ( presumably b/c the table does not exist )
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
thanks I'll try
furthermore, just to know
Can I use this "if -> else" format like below?
IF (blahblahblah) >0 BEGIN CREATE TABLE MyTable (...etc) END"
|
|
|
|
|
I think so. I've never executed SQL that complex outside of a proc, but I don't see why you shouldn't be able to.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
according to compiler
Compact Edition does not support the function OBJECT_ID()
I guess try-catch is the only solution
is it?
|
|
|
|
|
I would presume so. I am not surprised, CE is a very cut down version, designed to be portable, not complete.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|