|
Hi. i want to Get information for each table in DataBase.
especially i want to get column type and column size. (I want to use OleDb) i used OleDbSchemaGid and some select statements but most of its returns are (null) and doesnt have any useful information.
|
|
|
|
|
From where do you want to use OLEDB?
C#, VB.NET, Managed C++ or native code?
If the latter, there is stuff in ATL DB Client templates that will help.
Steve S
Developer for hire
|
|
|
|
|
from C# in a Windows form app
|
|
|
|
|
If your database is SQL Server try looking up Information_Schema views in the books online.
Select * from Information_Schema.Tables
will give list of all the tables.
--
Don't take life seriously because you can't come out of it alive.
-Warren Miller
(From Monty2[^] bio)
|
|
|
|
|
No. I want to use OleDb. I want to write a Program for all kind of Databases like access,Oracle and ... . is there any standard SQL statement for that.
|
|
|
|
|
hamidreza_buddy wrote: No. I want to use OleDb. I want to write a Program for all kind of Databases like access,Oracle and ... . is there any standard SQL statement for that.
You have to create separate connection for each type of database.
Regards
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
I guess not. Doing 10 Find() operations on a large table (55000 records) loaded into a BindingSource component always takes about 1.8 secs, with or without a primary key set on the column being searched.
Any ideas on how to add an indexed field to speed up searching?
Kees
|
|
|
|
|
I guess you've bound DataTable or DataSet to your control? If so, table is searched as it was an array of objects, not as a table in a database. Hence, indexes don't matter.
If you want index to speed up the process then you need to perform search by database. Just execute query again with different WHERE clause.
|
|
|
|
|
Thanks for your reply, your information is very clear.
|
|
|
|
|
I am having one physical table in which there are 5 columns and 20,000 rows (say first table) and i want to insert those rows into another physical table(say second table) but before insertion all rows into second physical table ,i need to fetch exact ids of each columns from diff-diff. tables from first phy. table and then when i get those ,insert those ids into second physical tables.
Here i am planning to use joins to fetch appropriate id but joins can only usefull when i give one row at a time.I don't want to use cursor to fetch single rows becoz it reduce performance.
is there any other way like for-loop in sql server 2005 from which i can loop throw one by one records(rows) till end of first physical table?
montu3377
|
|
|
|
|
While the following will sap performace ...
You can write a function that will take in parameters and then return the ID. Then you can write a simple looking select statement. It is heavy on the machine but works fairly well.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Can't you do something like this:
INSERT INTO table2 (field1,field2,field3,field4,field5)
SELECT (SELECT table3.field2 FROM table3 WHERE table3.field1 = t1.field1) AS field1,
field2,field3,field4,field5 FROM table1 t1 INNER JOIN table4 t4 ON t1.fieldx = t4.fieldy
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I have a VB.NET program that sits out on the network for people to access. This program makes numerous calls to a SQL database. There have been no changes made in the last few days. Today users are getting the error "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." IT said the server looks fine. What other items should I look at to find the problem?
|
|
|
|
|
If nothing else has changed, as you have stated, it is probably that the network load is heavy and client requests are not returning within the timeout period.
If the timeout is occuring during the connection to the database, increasing the connection timeout period in the connection string should solve the problem.
|
|
|
|
|
Your queries are probably not optimised very well. It's very likely that you don't have a suitable index to use on a particular column, which means that the query optimiser decides it has to read every row ('Table Scan' or 'Clustered Index Scan' depending on whether or not you have a clustered index), which means that the time to execute increases with every row added.
I look in SQL Profiler to find the most costly queries, then use the Show Execution Plan feature in Query Analyzer to see what the optimiser did. The easiest thing to do to speed performance is to try to spot the table scans and add an index which contains the fields it's looking for in the WHERE clause.
Note that adding indexes will have an impact on INSERT, UPDATE and DELETE operations, due to the need to maintain the indexes. You need to balance this cost against the improvement in lookup times - not just on SELECTs but of course INSERT, UPDATE and DELETE all need to find records, so the indexes can help with this too.
If you're looking up on only part of a compound primary key, and the key fields you have don't include the top level of the key, consider re-ordering the fields in your key, or supplying the rest of the key information to the query.
If it's not fast enough after doing this, check for Bookmark Lookup operations. This is where SQL Server is cross-referencing between the index it used to find matches and either the base table or the clustered index, in order to check other fields in the WHERE clause that aren't in the index, or output data that you have in the SELECT clause. If this is happening you can help it out by adding the extra fields to the index as well.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I use VCPP 6.0 and SQLExpress to connect to a database that contains 4 fields, one of the field holds the date and time. I want to be able to view entries between let's say 5 august 2005 21:30 and 8 august 23:30. I'm using the strFilter to run the queries but i got stuck when i was trying to use it on my date field. Should i separate the date from the time or smth? i think it's to late for my database.
|
|
|
|
|
Use stored procedures! (My fingers are getting cramped from writing that in this board)
in SQL you can
SELECT * FROM table WHERE effective_date BETWEEN @startDate AND @endDate
There are also methods to convert a date to a sting to make date only comparisons simple. Use yyyymmdd for this though.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Ok, I knew about stored procedures but i was trying not to use them, because, how should i put this, i don't know i'm new to both sql and VC++ and i don't know how to use stored procedures.
|
|
|
|
|
Ignorance isn't an excuse for bad design. The fact that you know about them and don't want to learn how to use them in a systems makes this a travesty. (With apologies for the blunt honest truth; i've had a long weekend)
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
I currently have this stored procedure:
<br />
@id as bigint,<br />
<br />
AS<br />
SELECT Meetings.meetinguser, Companies.name, Meetings.meetingdate <br />
FROM Companies INNER JOIN Meetings <br />
ON (Companies.id = Meetings.company) <br />
WHERE (Meetings.complete = 0)<br />
FOR XML AUTO, ELEMENTS<br />
Meetings.meetinguser is an ID number that also appears in the User table.
User.UserName is the name that coresponds to that ID.
At the moment this returns:
UserID CompanyName Date
I would liek it to return:
UserName CompanyName Date.
I was not sure about using more than one join in a single query...
Can any one, please, help ?
Thanks
-- modified at 5:07 Thursday 20th July, 2006
|
|
|
|
|
SELECT User.UserName, Companies.name, Meetings.meetingdate
FROM Companies, Meetings, User
WHERE Companies.id = Meetings.company AND User.id = Meetings.meetinguser
AND Meetings.complete = 0
ought to do it.
Steve S
Developer for hire
|
|
|
|
|
Simply add
INNER JOIN User
ON MeetingsUser.UserID = User.UserID after the existing ON clause and before the WHERE clause. You can have as many join clauses as you need.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Brilliant thanks guys
|
|
|
|
|
Anyone know how to set the lenght of the date???
Like
I have a product information here that i bought it from 1st Jan 2003, then the access will automatic set it warranty valid until 1st Jan 2004 if the user select 1 year warranty, if 2 year then 2005.
how do i set those queries??? anyone try b4?
i try to set the "actual date +365" for 1 year but it will come out as number , not the date.
|
|
|
|
|
campbells wrote: I have a product information here that i bought it from 1st Jan 2003, then the access will automatic set it warranty valid until 1st Jan 2004 if the user select 1 year warranty, if 2 year then 2005.
how do i set those queries??? anyone try b4?
i try to set the "actual date +365" for 1 year but it will come out as number , not the date.
Read up on the DateAdd function.
DateAdd[^]
exp DateAdd("yyyy",1,Date())
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|