|
Suppose the sql is :
select empno, empname, deptname,sal from emp, dept where emp.did= dept.did
I need the following:
If the column name is empno replace it by eno,
If the table name is emp then replace it by employee,
If the table is dept then replace it by department,
if the column name is did replace it by deptid.
That means after operation my the sql should be as follows:
select eno, empname, deptname, sal from employee,department where employee.deptid=department.deptid
I will be greatfull if any body help me to complete this.
I got a parser but it only can parse the column name in select statement and table names. But I am not getting the column names in the join condition. After getting the column name or table name how can I replce those?
Suppose I got emp as table but if I replace all the emp by employee then empname is also converting to employeename which is becoming to wrong column name
|
|
|
|
|
Use a Dictionary<string,string> ? Populate it with the old and new values. Split the existing statement and iterate the parts. If a part exists in the dictionary retrieve its replacement. Build a new statement.
|
|
|
|
|
I got some idea. But do you know any god parsers name where i can easily find out the column names, table names, join tables names columns in join condition, column in where clause, column in group by clause and having clause.
|
|
|
|
|
How to change color of RibbonControl, i am using RibbonControl.dll.
yogesh
|
|
|
|
|
I am not familiar with RibbonControl.dll and cannot therefore answer your question. I would suggest that you will get a better response if you ask the author of the control.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I would like to learn how to do for each. I have been researching. I also know this should be one of those no brainier questions but I am still piecing together how to make foreach for for me.
I know how to count my tables and fields then place the information in. But what I would like is to learn how to use the foreach command. to say something like.
Foreach (table in Database)
{
Foreach (column in table)
{
}
}
instead of counting the tables and columns and their names.
This will allow me to recreate a database from an existing one.
Any websites or information you can provide to point me in the right direction would be appreciated.
Just for reference purposes...
string sConnectString = "Driver={QODBC Driver for QuickBooks};DFQ=C:\\Quickbooks\\sample_company_file.qbw;OpenMode=M;OLE DB Services=-2;";
string sSQL = "SELECT Name FROM Employee";
OdbcConnection cn;
OdbcCommand cmd;
cn = new OdbcConnection(sConnectString);
cmd =new OdbcCommand(sSQL,cn);
try
{
cn.Open();
MessageBox.Show("open");
OdbcDataReader dr = cmd.ExecuteReader();
dr.GetSchemaTable().
MessageBox.Show(dr.GetSchemaTable().TableName);
}
catch (OdbcException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
cn.Close();
}
|
|
|
|
|
Not to poo-poo your question, but why are you writing code to do what sql already can?
Anyway - I'm not sure I actually get your question. If you're looking for the db/table/column structure info, you can use queries (which I'll inlcude at the end of this post) - but I'd try looking at the Interop.SQLDMO objects. Slow & a bit old-fasioned (I'm sure) but it works (I use it in a code generator I made) pretty well.
Aforementioned scripts:
-- select * From information_schema.tables -- (Tables)
-- select * From information_schema.columns -- (Columns)
-- Select * From syscolumns -- (another way to look at columns)
-- sp_fkeys([table] -- (fkeys for table)
-- SELECT FK.Table_name 'FKTableName', CU.column_name 'FKColumnName', pk.table_name 'PKTableName', pt.column_name 'PKColumnName',cu.table_catalog
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS C INNER JOIN
INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS FK ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME INNER JOIN
INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS PK ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME INNER JOIN
INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS CU ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME INNER JOIN
(SELECT i1.TABLE_NAME, i2.COLUMN_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS i1 INNER JOIN
INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS i2 ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME
WHERE
(i1.CONSTRAINT_TYPE = 'PRIMARY KEY')) AS PT ON PT.TABLE_NAME = PK.TABLE_NAME
where fk.table_name = '[table]' -- (Pkeys for table)
You're on your own with indexes and constraints (I'm not fiddling with that in my code generator).
Does that help, or did I miss what you're asking altogether?
|
|
|
|
|
I have a quickbooks database that I need to replicate into sql server.
The quickbooks database I have an ODBC connection to. But inorder to port the data from quickbook to sql server I have to generate the tables in sql server as they are in the quickbooks database. Then I can port the data from quickbooks to sql Server.
SQL Server has no odbc connection to quickbooks otherwise I agree with you.
I have found a piece of code that might help but I currently do not understand it.
http://stackoverflow.com/questions/47239/how-can-i-generate-database-tables-from-c-classes[^]
|
|
|
|
|
I have an application that looks for the next job to process by querying a que table. If it finds a record it does some processing for the corresponding job and then removes that record from the que table. I want to have this application running on more then one server but I'm not sure the best way to keep each instance of the application from trying to process the same record in the que table. Somehow when one instance of the application begins processing a record in the que table it needs to flag that record so that another instance of the application will not process it. What is the best way to do this?
|
|
|
|
|
If you return the info from your table and update the "Processing" flag from within a transaction, the other processes wont overlap due to l ocking caused by the transaction.
|
|
|
|
|
|
I want to know how can I do a random rename to all files in a specefic folder, for example, rename every file name from the current file.jpg to a GUID.jpg then it will be unique and random?
|
|
|
|
|
You've just asked, and answered, a question all in one go. 'grats.
|
|
|
|
|
jrahma wrote: GUID.jpg
yes, GUID is quinque.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Manas Bhardwaj wrote: GUID is quinque.
That many
|
|
|
|
|
Hi,
have a look at Path.GetRandomFileName()
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
hi,
how to convert pdf file format to tiff file format?
I need source code.
regards,
Bill
|
|
|
|
|
billcodes wrote: I need source code.
Do you need it with an all consuming, burning desire? Can you not sleep at night, sweating as you think about all the code that has been lost to you, lost as it cavorts with others, dancing the night away like the brazen harlot that it is? Is it the mistress that drives you wild with desire, while you know that you shouldn't be seduced by the sultry temptress?
You are going to either have to buy (or download open source) components that do this, or you are going to have to write code based on the file formats, both of which are freely available on t'internet.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: Can you not sleep at night, sweating as you think about all the code that has been lost to you, lost as it cavorts with others, dancing the night away like the brazen harlot that it is? Is it the mistress that drives you wild with desire, while you know that you shouldn't be seduced by the sultry temptress?
That's me
|
|
|
|
|
Pete O'Hanlon wrote: Do you need it with an all consuming, burning desire? Can you not sleep at night, sweating as you think about all the code that has been lost to you, lost as it cavorts with others, dancing the night away like the brazen harlot that it is? Is it the mistress that drives you wild with desire, while you know that you shouldn't be seduced by the sultry temptress?
You've take up writing trashy novels, haven't you?
You better stop this - you might start turning the newbies on in ways you never thought possible!
|
|
|
|
|
Dave Kreskowiak wrote: you might start turning the newbies on in ways you never thought possible!
Ooh yuck.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hi
in my project i am using grid view to show data. at the same i want to allow the user to make changes in grid view and also can new record in it and at save button all data save to the database.
it is pretty simple if acheive with SqlDataAdapter as achieve in An ADO.NET multi-database, multi-tier solution by using methods SqlDataAdapter.Fill() and SqlDataAdapter.Update()
now help me how can achieve it via linq
|
|
|
|
|
|
Hi
Hello I am a windows base Developer recently go for web application development please help me I don’t know how to using the java script using ASP.net and C# how to when I click the button. popup calendar appear then select the date value to pass the that value to another page give a sample of the code
|
|
|
|
|
This post is better suited in the ASP.NET forum.
(Also, my guess is that Google will give you a lot of hits with tutorials on this issue..)
|
|
|
|