|
if I declare them outside the loops
string sql1;
string sql2;
string sql3;
etc
then inside each for loop I have a sql query like
for ()
{
sql2 = sql1 + "where bla bla";
}
for()
{
sql3 = sql1 +"where bla bla";
}
Obviously sql1 and 2 and 3 etc are never assigned as they are defined outside the loops and it never picks up their value?
This is what the error is telling me anyway.
Thanks
|
|
|
|
|
ah...i think I worked it out now. I'm not sure if that is what you were trying to tell me anyway, but I have declared the common query outside all the loops like this
string sql = "Select e.Firstname,e.Lastname,r.Role,r.Description,d.DivisionName,a.Applications,m.ManagerFirstname,m.ManagerLastname,t.ProgLanguagesDatabase" +
" from employees e,Role r,Division d, Manager m, TechnicalSkills t,Applications";
then later i have used sql2 = sql + "where etc";
Is this the correct way?
thanks
Sharny
|
|
|
|
|
I expect each loop would end up adding a query to the main sql string, but, it's hard to say, I'm not entirely sure why you're putting strings in from more than one loop, or what the end product is to be. But yes, having one string to hold all the SQl was my suggestion.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thankyou. I need to have nested loops because I've got multiple user search options on a windows form. I have it working baced on what I said. I just had to do a bit more trial and error and I would've worked it out without asking.
Thank you
|
|
|
|
|
Hi.
How can I backup from DB (SQL Server) in code ?
Or using sql statements?
Best wishes
|
|
|
|
|
I think you can use stored procedures to create backups of the database. I don't remember what it is called.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi, all.
Is there any solution to intercept SQL statement on client workstation, stop it temporary, make some edit operations with WHERE clause, and send an upadated SQL to server?
Can i make it using C++? I've never met this task yet, so, could you tell me, where a have to dig (documentation, links, e.t.c). I'm interested in Oracle and SQL Server solutions. Maybe there is ready example?
Thanks a lot.
|
|
|
|
|
LinCorJDE wrote: Is there any solution to intercept SQL statement on client workstation, stop it temporary, make some edit operations with WHERE clause, and send an upadated SQL to server?
I think it would be better if you told us the bigger picture because I can't imagine this would be a very good solution to anything other than an attack on the database.
|
|
|
|
|
OK, try to do it.
So, we have ERP system "Oracle JDEdwards Enterprise One".(Who knows about this system - they understand me ) It generates SQL statement using visual tools:
link tables using "drag and drop", create WHERE statement using "mouse" method, not manual writing. I can add own WHERE's using only visual components. And there is no GROUP BY (!), i can not use any hints, and using SELECT in WHERE statement is impossible. All i need is to edit WHERE statement in system generated SQL.
|
|
|
|
|
|
|
Please don't cross post and please don't put Urgent in the title.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
Cheers.;)
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
You say "dont" he says "will do" and you say "cheers"?? Fun language this...
|
|
|
|
|
I have a table, that has an Identity Column as a Primary key.Suddenly there are some Dublicate that have same idenitity Column ID, and they look identical. i cant remove the Duplicates because they have the same ID. please help me to remove the Duplicate.
thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hmmm. Did you remove the unique constraint from your primary key field by any chance (the identity column is a primary key, isn't it)? This constraint is there to ensure that you can't have duplicate fields.
Anyway, there are a number of ways that you could do this, but the implementation really depends on factors such as do you have foreign keys linked to your table? If so, then you really need to be careful about deleting.
A quick thought has occurred to me - how did you select these records? Are they part of a multi-table select? If so, it is likely that what you are seeing is the result of a one-to-many relationship. Try selecting the data out of the table on its own.
If a single table select still produces duplicate data and it's not a part of a foreign key then you can do the following:
Open up your table in the designer and drop the identity column. Save it to the database. Then add the identity column back into the table and save it again. The stages here drop the identity column and then force the database to apply a new identity column - which will have the effect of giving a new Id to each record. Voila - you now have unique rows.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
Thanks for your reply
i did not remove the primary key Constraint. And there is a Foreign key linked to this table.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
I fail to see how you've got this problem then because the unique constraint prevents duplicate data from being posted. The identity column is the primary key isn't it?
BTW - just a quick confidence test. You are using SQL Server aren't you?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
yes, it is the Primary key, i have not used the Unique Constraint, sorry about that. i thought if i make a Column Primary key and its identity. it will enforce the Uniqueness. my Field is a Primary key, and i have not defined the unique constraint.
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Vuyiswamb wrote: yes, it is the Primary key, i have not used the Unique Constraint, sorry about that. i thought if i make a Column Primary key and its identity. it will enforce the Uniqueness. my Field is a Primary key, and i have not defined the unique constraint.
Surely if the field is the primary key, the database would not have allowed you to fill duplicate values in the first place?
And I also noticed that you said something like "looked identical" in your first post... how did you determine that you had duplicates in your table?
|
|
|
|
|
i have used a Query to Determine that.
SELECT *
FROM sde.Property p1
WHERE (FUNC_KEY = 'PV000000') AND EXISTS
(SELECT 1
FROM sde.Property p2
WHERE p2.lis_key = p1.lis_key
HAVING COUNT(p2.Property_ID) = 2)
order by Property_ID Asc
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
What happens if you just say
SELECT * FROM sde.Property WHERE (FUNC_KEY = 'PV000000')
how many records do you see?
|
|
|
|
|
i see Records with Dublicates in Property_ID.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Vuyiswamb wrote:
i see Records with Dublicates in Property_ID.
Then it looks like Property_ID is not the primary key of this table.
|
|
|
|