pitic 15 Newbie Poster

Creating /altering table at run time is not a good idea.

why not create the table before executing any insert.

i'm creating it like a temporary table. i have a drop statement after inserting values. the whole process is like this:

i have a table with data which i need to update/replace.
1. copy data from t1 to t2 (in case something goes wrong)
2. delete data from t1
3. create table t3 from xml (insert from xml)
4. update table t3 with values from another xml
5. copy data from t3 to t1
6. drop t3

edit: the reason i cannot create it is because i do not know the column names/types and number of columns untill i parse the xml

pitic 15 Newbie Poster
[B]Book mybook = new Book();[/B]
        public void checkRatio()
        {
            const double RATE = .10;
           
            
            // The price-to-pages ratio is determined by checking the following:  price > RATE * pages where RATE = 0.10
            if (Price > (RATE * NumPages))
            {
                [B]mybook[/B].validRatio = true;
            }
            // Throw a BookException if a book object is created that has a price that is more than 10 cents per page
            else
            {
                [B]mybook[/B].validRatio = false;
                BookException be = new BookException();
                /* Create an error message that is passed to the Exception class constructor for the Message property 
                * when a book does not meet the price-to-pages ratio. */
                Console.WriteLine("Ratio for {0} is invalid. Price is {1} for {2} pages.", Title, Price, NumPages);
                throw(be);
            }
        }

    }  //End Book Class

you are creating an instance of class book inside the class declaration. remove the line in bold, and inside the checkRatio() method just use the cariable names (without the preceding object)... c# is clever enough to use the object you created in main.

pitic 15 Newbie Poster

Hello,
I have the following situation which I can seem to resolve. When I do an "ALTER TABLE" in mysql (v5.5) it hangs in with "waiting for metadata lock". Here is how I got there:

- i have an xml which i want to import into a table; i use the elements in the xml to create columns in the table like this:
XML example

<name> some name </name> <address>dsada</address>
there are some nodes in the xml that have different number of elements, like:
<name> some name </name> <address>ds adsa</address> <phone> fndjsf</phone>

SQL queries

create table `person` ( `id` bigint(12)  unsigned NOT NULL auto_increment ,`name` varchar(200) NOT NULL ,`address` varchar(250) NOT NULL ,PRIMARY KEY  (`id`),) ENGINE=MyISAM DEFAULT CHARSET=latin1 
insert into person(name, address) values ...

the column names are read from the xml, so are the values. If the for loop reads a column name that hasn't been created in the table yet, like "phone" it returns a sql exception "column name "phone" not found" and tries an alter table before inserting the values
alter table 'person' ADD COLUMN `phone` varchar(20) NULL default NULL;
here is where the program hangs. i've checked in mysql admin for the session and the state is "waiting for metadata lock"

how can i pass this? or how do i remove the table metadata lock created by the previous insert which raised the exception. (the import is made in java that's why i use a for loop to …

pitic 15 Newbie Poster

Hy,

I have the following application:
- server application that uses a digital certificate to login to a website; first time i run the app it requires the pin number from the token... certificate is stored on token); i use X509CertificateUI to select the certificate and it pops-up the token client to enter pin number;
- client application connects to my server app and send some data which the server passes to the website to get response and send back to the client.

Everything is working ok. BUT... i want to make it a windows service. (currently is form based). I have done the service part, i installed it, can start it from the service manager, but it doesn't show the certificate selection and the token client for the pin.

here is the server code to get the certificate;

var store = new X509Store("MY", StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
 
            X509Certificate2Collection selection = X509Certificate2UI.SelectFromCollection(store.Certificates,
                                                                                           "Digital Certificates",
                                                                                           "Select a certificate from the following list:",
                                                                                           X509SelectionFlag.
                                                                                               SingleSelection);

After i select it and enter the token pin number it works ok, but haven't been able to do the same as a windows service. I have also exported the certificate into a file from the token and declared a x509cert from local file but it should also require the token pin number.

X509Certificate2 localCert = new X509Certificate2(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\my.cer");
            return localCert;

thanks

pitic 15 Newbie Poster

ey. Thanks for the reply, but what you suggested does not apply for me. I'm trying to select from 3 different tables from each of the 3 databases the rows which contain a certain value. In the mean time i have completed the query selecting the rows from one table, union them with the other tables in one database, then union the whole select with the other two databases.
Here is what i did

SELECT * FROM (SELECT id, "t1", "db1" FROM db1.t1 WHERE p_id = ""
UNION SELECT id, "t2", "db1" FROM db1.t2 WHERE p_id = ""
UNION SELECT id, "t3", "db1" FROM db1.t3 WHERE p_id = "") s1
UNION
SELECT * FROM (SELECT id, "t1", "db2" FROM db1.t1 WHERE p_id = ""
UNION SELECT id, "t2", "db2" FROM db2.t2 WHERE p_id = ""
UNION SELECT id, "t3", "db2" FROM db2.t3 WHERE p_id = "") s2
UNION
SELECT * FROM (SELECT id, "t1", "db3" FROM db1.t1 WHERE p_id = ""
UNION SELECT id, "t2", "db3" FROM db3.t2 WHERE p_id = ""
UNION SELECT id, "t3", "db3" FROM db3.t3 WHERE p_id = "") s3

If you have a better option for this I'm looking forward to see it, because this gets really crowded when i have more tables and databases. And yes, I am using MySql and all the databases are on the same server. The db-s are the same with db1 being main and the other are backups which differ only in the content not in fields …

pitic 15 Newbie Poster

Hy. I'm trying to do a select from multiple databases and tables for an occurence.

let's say i have databases db1, db2 and db3. Each have the following tables t1, t2, t3. And in each table there is a field named id which i want to select and a field and p_id which i want to use as a condition. To give a better idea this is an example of what results i want to get:

---------------------------------------
|id_t1 | id_t2 | id_t3 | database_name|
---------------------------------------
| 100  | 123   | 356   | db1          |
| 252  | 156   | 566   | db2          |
|...   | ...   | ...   | db3          |
---------------------------------------

How can i pass the p_id condition to each table and each database. I tried this: select t1.id as id_t1, t2.id as id_t2, t3.id as id_t3, (select database()) as database_name from db1.t1, db1.t2, db1.t3 where ****can't make the condition work because if i only say p_id = 100 it says it's ambiguous**** union select *** all the above *** from db2 and db3 I have also tried with join but it's not what i want (at least how i tried it) because there is no link between tables.

Thanks