|
Also, assuming that you're using SQL Server 2000 (or MSDE) have a look at:
sp_getapplock
sp_releaseapplock
In most of the situations where our OLTP system has concurrency issues, I've found app locks to be infinitely more useful than transactions. Transactions (IMHO) should be used for atomicity, not for concurrency issues.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
|
|
|
|
|
This will work.....
But i am using Oracle and also i want to handle this at BLL but not in database.
|
|
|
|
|
Couple of Query questions:
1. is there a way to step through a query and view variables in the Anaylzer for MS SQL Server ?
2. I'm attempting to create a query that will be run dailly for the previous day's infomation, I'm having trouble getting the previous date in a usable format.
The following uis what i have so far:
DECLARE @Year int
DECLARE @Month int
DECLARE @Day int
DECLARE @FullDate varchar(10)
DECLARE @Yesterday datetime
SET @Yesterday=DATEADD(day,-1,GETDATE())
SET @Year = CAST(DATEPART(yyyy,@Yesterday) as varchar(4))
SET @Month = CAST(DATEPART(mm,@Yesterday) as varchar(2))
SET @Day = CAST(DATEPART(dd,@Yesterday) as varchar(2))
SET @FullDate=@Year+'-'+@Month+'-'+@Day
SELECT * FROM Document WHERE (ProcessDate=@FullDate)
Can someone point out where I'm going wrong ?
|
|
|
|
|
Couple of Answers:
1) Create a stored proc and debug it. You debug buy r-clicking on the stored proc in anaylzer and chosing debug. Just destroy the SP if you don't need it.
2) I believe that creating dates from strings is dependent upon SQL Server localization settings. What I answer here may not work exactly the same on your setup.
I have created a UDF to handle the removal (set to 12am) of time information from a DATETIME. \
CREATE FUNCTION DateOnly
(
@Test_DT DATETIME
)
RETURNS DATETIME
AS
BEGIN
DECLARE @tmp DATETIME
SET @tmp = CAST(CONVERT(VARCHAR(20),@Test_DT,101) AS DATETIME)
RETURN @tmp
END
Given this function installed in your database, your query would look like this:
DECLARE @Yesterday DATETIME
SET @Yesterday = DATEADD(d,-1,dbo.DateOnly(GETDATE()))
SELECT * FROM Document WHERE ProcessDate = @Yeseterday
My SQL installation is set for American style dates. This may not work unchanged in your system. Check out the options in the CONVERT() function in Books-On-Line for what will work best in your locality.
|
|
|
|
|
Hi,
I have a problem. I try to load a table into a DataSet. The problem is that the rows that are recieved in the DataSet are duplicated. Say we have 3 records (1,2,3), I get in the DataSet 6 (1,2,3,1,2,3).
When I read using a DataReader the amount recieved is just fine.
Does anybody know what the problem may be?
Here is the code:
OleDbCommand commandNeType = new OleDbCommand("SELECT * FROM NeTypes WHERE Index = ?", m_connection);
commandNeType .Parameters.Add(new OleDbParameter(DB_NeTypes.FLD_INDEX, OleDbType.Integer, 0));
commandNeType .Parameters[DB_NeTypes.FLD_INDEX].Value = index;
OleDbDataAdapter daNeType = new OleDbDataAdapter(commandNeType);
try
{
daNeType.Fill(m_ne, TBL_NETYPES);
}
catch (Exception e)
{
closeConnection(ref m_connection);
return (int)ERR_DB.FILL_DATASET;
}
// create table
DataTable tableNeType = new DataTable();
tableNeType = m_ne.Tables[TBL_NETYPES];
now this: tableNeType.Rows.Count returns twice the amount of actual rows.
Thank you!
|
|
|
|
|
I dont think u will get double the amount..just try out...there is no way u can receive double the amount.
|
|
|
|
|
This should be a simple answer for most people, but its stumping me.
I need to query a table for all records that are between two dates, but my query staement return no values, can someone tell me whats wrong ?
SELECT * FROM MyTable WHERE (WorkValue=15 AND (ProcessDate>'5/19/2004' AND ProcessDate<'6/16/2004'))
|
|
|
|
|
I always put the dates in in ISO format. e.g. '2004-05-19'
Also, have you checked there is actually data for that date range with WorkValue=15
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Yes, I have also tried
SELECT * FROM Document WHERE (ProcessDate>'20040519' AND ProcessDate<'20040616') ORDER BY ProcessDate
and Yes there are plenty of records that fall within the requested date range.
|
|
|
|
|
Try SET DATEFORMAT ymd first. The US English default is MDY, i.e. '04/19/2004'; yours may be different though.
|
|
|
|
|
You may need to use the CONVERT function. I.e. your SQL server is not understanding the date you submit in the query.
|
|
|
|
|
Steven Campbell wrote:
Try SET DATEFORMAT ymd first.
That won't make any difference. SQL Server always understands yyyymmdd date formatted strings, because that's the ISO standard. (Format 112 in a CONVERT statement.) Likewise, SQL Server always understands yyyy-mm-dd because that's the ISO8601/ODBC standard.
My question to Guinness is, whether that's the EXACT query you're using in query analyzer, or is it version that's been simplified for our benefit?
Grim (aka Toby) MCDBA, MCSD, MCP+SB
|
|
|
|
|
I recving error .
No Clomns were bound prior calling go SQLFetchscroll/SQLExtrendedFetch ..
wt it measn n who it should b handled ,, steps?
thanx
|
|
|
|
|
Please help me in the coding to solve this problem if you know it.
I create a frmCustomer that contains of txtCustID, txtCustFName,txtCustLName,txtCustDob and txtCustIC.... and the Add button, Search button and Exit button. When the user click on the Search button, the frmSearch will show. The user can search for the customer by select the alphabet in a combobox. The details of the customer whose last name start with that alphabet will display in the datagrid.
The datagrid in ths frmSearch contains of CustID, CustName, CustDoB. When the user double click on the specific row of the datagrid. It will retrieve the records from the Customer table in SQL server by passing the CustID and display the CustID, CustFName, CustLName, CustDob, CustIC.... to the txtCustID, txtCustFName,txtCustLName,txtCustDob and txtCustIC....on the frmCustmer. Then, the user can do the edit or delete of the record by pressing the button.
Please help.
Thanks and Best regards,
Vivian;)
|
|
|
|
|
I'm need to run a query from ACCESS 2000 that will extract data from a progress server and dump it into an ACCESS database. I have to specify the fields that I want to extract and I was already able to do so.
The problem was, there is this field TAX_due that is giving me the *hit. ACCESS gives an error message ' Scaling of Decimal Values Resulted in Data Truncation and then the query would stop.
how can I just trucate and ignore the loss data and go ahead anyway? I just aquire about 30 records then it kaboofs because of this error.
anyone, help plz.
TY!
|
|
|
|
|
Hi,
I'm making an OleDbConnection using the Sybase ASE OLE DB Provider with the following code:
_____________________________________________________________________
OleDbConnection oDbConn = new OleDbConnection(sConnectionString);
OleDbCommand oCmd = new OleDbCommand("SELECT * from master.table;", oDbConn);
OleDbDataAdapter oData = new OleDbDataAdapter(oCmd.CommandText, oConn);
DataTable oTable = new DataTable("master.table");
oData.Fill(oTable);
__________________________________________________________________
The database I'm connecting to -requires- a semi-colon at the end of the SELECT command. I've tried ending my SELECT with a semi-colon (see above) but one of my OleDb objects is removing it before it is sent to the database as I can see the following databas error when running my program:
SQL Parser: parse error at line 1.
Command: SELECT * from master.table
Issued by:
How do I control the SQL statements sent to the database via the OleDbConnection so I can add a semi-colon to my SELECTs??
TIA,
Matt
|
|
|
|
|
could you explain why you need a ';'
and also see if you can use a stored procedure to achieve the same.
Bhaskara
|
|
|
|
|
I'm sure we'll be more likely to help with your homework if you first learn how to type. Actually, on second thoughts, we probably won't. Do your own homework, and let us know when you get stuck. Once it looks like you've made some effort, I'm sure many people will be glad to help you if you get stuck.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
wgdesigner wrote:
I think u don't have any knowledge
Well, for starters, I can spell. That puts me ahead of you. And I could care less what you think. Who the hell are you ?
wgdesigner wrote:
and u don't want help anybody without ur profit...
You're right. That's why I was reading the questions forum in the first place, why I write articles here, and why I suggested that I'd be happy to help you if you were willing first to try and do your own homework. Idiot.
wgdesigner wrote:
By the way if u don't want to help then it is not matter but don't try to be oversmart bzz ur not!!!!
bzz ur not ? Man, are you this stupid, or do you think that being unable to spell makes you cool ?
wgdesigner wrote:
I want to find out the two record in database first and last record without veiwing the database tell me
Why would I tell you ? Because I 'know nothing', or because you've just been insulting me ?
wgdesigner wrote:
iam a graduate in computer science understood...
You're a graduate but you can't spell and you can't string together a simple SQL query ? I doubt it.....
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Would you like to be forcefully removed from the site? Based on the professionalism you've shown in your last post, I seriously doubt you have a degree in Computer Science. And if you do, I question the quality of the institution where it came from.
Oh! This is my one SQL statement to get me in the door here:
SELECT * FROM myTable WHERE myID LIKE 'WhoCares!'
Now, back to your question. I can't make heads or tails of what your asking. Ideas about what? All you said was you have a bank with a central server and a bunch of other banks that connect to it once a day. To do what?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
He swears just fine in English, doesn't he?
Sounds like the trailer-trash I live next to.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yeah, I got an autoreply on an abusive post he made to me, he seems since to have packed up his trailer and moved on
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
We currently use the .net SQL Server managed data provider for database access, but we are looking at possibly extending our app support to Oracle. The .net Oracle managed data provider looks like a good solution, but it brought up some questions. What support does Oracle provide for a GUID data type? What versions of Oracle support this? We notice that the Oracle data reader has the same GetGuid() SetGuid() that SQL Server provides, but are not sure how it is implemented in an actual Oracle table.
So if anyone has any info on this (or can give us a juicy link with this info) us non-Oracle guys would appreciate it!
Michael
Developer, Author, Chef
|
|
|
|
|
We are having a bit of a problem with a remote client using our software to access a JET database via ado.
I've got a few hunches on what the problem might be but I need to test this on a machine with an older MDAC and JET provider setup.
Does anyone know if Microsoft still have download sites for older service packs of the JET 4.0 files?
I Dream of Absolute Zero
|
|
|
|
|
You can't get just the JET stuff, you have to install the entire MDAC. You can do to http://download.microsoft.com[^] and search for the keyword MDAC to get the eariler versions.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|