|
Programmatically, or for diagnostic purposes?
For diagnostics, use the MDAC Component Checker[^].
The snapshots included with the tool can be somewhat misleading - I don't think I've ever had any system installation, including a completely clean install, report no errors with this tool. But it'll make a fairly good identification.
|
|
|
|
|
I have a varchar(30) variable which holds data I want, a '$' and then some more data I want. Basically, I'm trying to cheat and return 2 dates from one function, and this seemed one way to do it.
My problem is this - I want to get the two dates in the sp this string is returned to. I was thinking of finding the position of the '$', then the characters before it will be the first date, and the characters between it and the end of the string will be the second date. The problem is, I'm having trouble getting the position of the '$'.
Any ideas?
I hope I'm making sense
Look at the world about you and trust to your own convictions. - Ansel Adams
Photography[^]
|
|
|
|
|
--first date
SUBSTRING(1, CHARINDEX('$', variablename))
--second date
SUBSTRING(CHARINDEX('$', variablename) + 1, LEN(variablename) - CHARINDEX('$', variablename))
You may have to adjust by adding/subtracting 1 to get proper results
|
|
|
|
|
Thought of using a table-valued function?
CREATE FUNCTION dbo.fnGetTwoDates
(
@searchCriteria varchar(30)
)
RETURNS @twoDates TABLE
(
FirstDate datetime,
SecondDate datetime
)
AS
BEGIN
INSERT INTO @twoDates
SELECT
RETURN
END
Usage:
SELECT FirstDate, SecondDate
FROM dbo.fnGetTwoDates( 'criteria' ) Now, if only we could pass tables INTO stored procedures as parameters - I'm stuck with using temporary tables with fixed names in order to modularise some very large (>1000 line) procedures.
|
|
|
|
|
SELECT [ID], Title, NodeType, ParentID, [Language], Description FROM SourceCode WHERE Title LIKE '%Title%' OR Code LIKE '%Title%' AND Language = 1 OR Language = 2 OR Language = 3 OR Language = 4 OR Language = 5 AND NodeType = 1 OR NodeType = 2 OR NodeType = 3 OR NodeType = 4 OR NodeType = 5 OR NodeType = 6 AND ParentID = 4 OR ParentID = 6
Do the numbers have to be quoted?
Any Suggestions?
Thank You
Bo Hunter
|
|
|
|
|
AND operator has a higher priority than OR . You might want to use parentheses:
SELECT [ID], Title, NodeType, ParentID, [Language], Description
FROM SourceCode
WHERE (Title LIKE '%Title%' OR Code LIKE '%Title%')
AND (Language = 1 OR Language = 2 OR Language = 3 OR Language = 4 OR Language = 5)
AND (NodeType = 1 OR NodeType = 2 OR NodeType = 3 OR NodeType = 4
OR NodeType = 5 OR NodeType = 6)
AND (ParentID = 4 OR ParentID = 6)
HTH,
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
Furthermore, you really ought to use "IN":-
SELECT [ID], Title, NodeType, ParentID, [Language], Description
FROM SourceCode (nolock)
WHERE (Title LIKE '%Title%' OR Code LIKE '%Title%')
AND Language IN (1,2,3,4,5)
AND NodeType IN (1,2,3,4,5,6)
AND ParentID IN (4,6)
#include <beer.h>
|
|
|
|
|
Will the IN operator work in Access?
I forgot to mention that.
And also some of the idetifiers like Language
has to be exscaped. Does that also have to be
exscaped in OleDbParameter like so,
OleDbParameter param = new OleDbParameter( "[Language]", bla bla );
Is this correct?
Thank You
Bo Hunter
|
|
|
|
|
Bo Hunter wrote:
Will the IN operator work in Access?
Yep, it will.
Bo Hunter wrote:
Does that also have to be
exscaped in OleDbParameter
Probably it has to be escaped. This won't hurt anyway
Alexandre Kojevnikov
MCAD charter member
Leuven, Belgium
|
|
|
|
|
Hi all,
I'm having the following problem: my site can access the database perfectly, using an ODBC-less connection, but when I try and insert or edit records I get the error "Cannot update. Database or object is read-only." I have changed all permissions in IIS, and in Windows Explorer but I can't seem to get it working. Suggestions please?
The connection string I'm using:
(driver: Microsoft.Jet.OLEDB.4.0)
var sConnectionString = "Provider=" + sDBDriver + "; ";<br />
sConnectionString += "Data Source=" + Server.MapPath("../../bin/db/db.mdb");
Paul
Tiny problem with said member has been corrected. Chris Maunder
modified 18-Jul-18 11:59am.
|
|
|
|
|
Fixed
Paul
Tiny problem with said member has been corrected. Chris Maunder
modified 18-Jul-18 11:59am.
|
|
|
|
|
How?
"Welcome to Arizona! Drive Nice - We're Armed..." - Proposed Sign at CA/AZ Border
|
|
|
|
|
I had to give IUSR_<computername> read and write access to the directory containing the Access DB.
HTH
Paul
Tiny problem with said member has been corrected. Chris Maunder
modified 18-Jul-18 11:59am.
|
|
|
|
|
Ah, of course... I've run into similar fun and games simply hosting files on IIS for public access. I assumed that the Everyone group included IUSR_... but never bothered to look. I still haven't, in fact, but found empirically that adding IUSR access to hosted files suddenly made them accessible from the outside world.
"Welcome to Arizona! Drive Nice - We're Armed..." - Proposed Sign at CA/AZ Border
|
|
|
|
|
|
Hello
I have a problem while trying to edit a record on SQL Server 2000 (Sp 3).
The problem occures, w hen I click to "Return all rows" in the context menu of the table, and I tried to uptade a record .
It occures an error. The error message says : "Transaction cannot start while in firehose mode"
I have researched a little about firehorse, but could not find any useful information.
I look forward to hearing from you
thanks
Best Regards
Emre YAZICI
|
|
|
|
|
Firehose mode or firehose cursor is a forward only readonly way of going throug data.
Is this in Enterprise Manager? Is this problem consistent, or only on a certain table?
|
|
|
|
|
thanks for your help
There are lots of tables, It occures just for ONE table.
We are using a client of a network
The database is on the SERVER of the network
There is a strange thing that I do not understand
I am able to update the record , when I add a new record.
e.g.
There are 10 records
I have added a new one, after I updated the 8th one .
After this there are 11 records, and the 8th record has been updated successfully.
please contact for further information if necessary
Best Regards
Emre YAZICI
|
|
|
|
|
Hi..
When I try to run the following SQL against my SQL server in MFC i only get "No records" in return
(complete CDaoRecordset opening string)
rs.Open(AFX_DAO_USE_DEFAULT_TYPE, _T("SELECT * FROM scala_A_SL010100 WHERE FNCustomerName LIKE '%AB%'"), 0);
(sql query)
SELECT * FROM scala_A_SL010100 WHERE FNCustomerName LIKE '%AB%'
But if i run the exact same sql query in the SQL Query Analyzer it returns 167 posts..
Any one who has any idéas??
|
|
|
|
|
Perhaps DAO isn't passing the query into SQL Server as-is?
I suggest using ODBC to connect to the database, i.e. use the CRecordset and CDatabase classes rather than CDaoRecordset .
|
|
|
|
|
I think it's much easier working with CDao classes...
And the way the program is ment to be used, i can't create System-DSN's on all computers (to be able to use ODBC) I would like to connect directly to the SQL server...
One strange thing I've noticed is that if I use very simple SQL queries such as SELECT * FROM scala_A_SL010100 or SELECT * FROM scala_A_SL010100 WHERE FNCustomerName LIKE 'Besam AB' .. Or something else without the % it works fine..
Iv'e also noticed that it doesn't work then i use joins.. but as I
SELECT DISTINCT scala_A_OR200100.FNSalesmanNo AS 'Salesman', scala_A_SYCD0100.FNCurrencyShortName AS 'Currency', scala_A_OR120100.FNOrderNumber AS 'Ordernumber', scala_A_OR120100.FNLineNumber AS 'LineNumber', scala_A_OR120100.FNStockCode AS 'StockCode', scala_A_OR120100.FNDescripLine1 AS 'DescLine1', scala_A_OR120100.FNDescripLine2 AS 'DescLine2', scala_A_OR120100.FNUnitPrice AS 'UnitPrice', scala_A_OR120100.FNQty AS 'Qty', scala_A_OR120100.FNDelDate AS 'DelDate', scala_A_OR120100.FNOrderDate AS 'OrderDate' <br />
FROM scala_A_OR200100 right outer join scala_A_OR120100 <br />
ON scala_A_OR120100.FNOrderNumber = scala_A_OR200100.FNOrderNo <br />
right outer join scala_A_SYCD0100 <br />
ON scala_A_OR120100.FNUnitCode = scala_A_SYCD0100.FNCurrencyCode <br />
WHERE scala_A_OR120100.FNCustCodeDel = '400002' <br />
ORDER BY scala_A_OR120100.FNOrderNumber Desc, <br />
scala_A_OR120100.FNLineNumber asc"
But it works perfectley in the Query Analyser...
If I take away the last join it seems to work without any errors, but I naturally don't recieve all data I need..
I wonder if he DaoClass can't cope with a little more advanced SQL queries.. Or if it may be something i've done wrong.. And if there may be some way to fix my problem??
(ps. been on a vaccation a few days, therefore I havn't replied until now ds.)
|
|
|
|
|
Well I have come to a stop on this one;
I have a Nodes table with 4 columns ( ID, ParentID, Name, IsRoot )
I have sample data entered in
ID=====ParentID=====Name=======IsRoot
1 =====0 ==========Title1======True
2 =====0 ==========Title2======True
3 =====0 ==========Title3======True
4 =====1 ==========Child1======False
5 =====2 ==========Child2======False
6 =====5 ==========Child3======False
Now when I do a search and include sub categories
I need all the sub categories IDs. Now if I pass
ID 2 for a search then I need to get 5 and 6; I have 2 already
as it was passed in to the function; So it will look
something like Select Whatever From Nodes Where
( ParentID = 2 OR ParentID = 5 OR ParentID = 6 ).
The reason this is so hard for me is I am not filling
a dataset with all the data because it will get rather large
and take a long time to load all the data. So I am
populating the nodes as the user selects them. This
is the only method I like.
Thank You
Bo Hunter
|
|
|
|
|
Personally I would use two tables
Parent Table (id, name)
Children Table( id, parent_id, name)
|
|
|
|
|
I'm not sure I understand your question...
Are you trying to build a query in which given a node ID, you get the node's children, the children's children, etc.?
- Mike
|
|
|
|
|
I am not tring to build the query but the methods to do what you
are saying. So if I pass 2 to the function then I need to be able
to get the children of that node and then get the children for these
nodes and keep doing it until there is no more results. I had this
done using a recursive function on the TreeNodes in the treeview.
I added these ID and ParentID properties to the treenode derived class
but forgot that if the node has not been loaded then it does not return
all the chilren. Calling a function recursively using a DataReader does
not work to well
Thank You
Bo Hunter
|
|
|
|