|
as Syed said - STORE YOUR DATES AS DATETIME. This is a fundamental error in design and you should be smacked for using nvarchar. You are now going to forever need to cast/convert that column to do anything with it.
More emphasis - USE THE CORRECT DATA TYPE
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yeah, what they said... or at least use an ISO 8601 compliant format YYYY-MM-DD.
|
|
|
|
|
using C# and SQL Server 2005
Instantiate a data adapter on startup and re-use.
No problems when 1 station running.
When a number of stations running at the same time, data adapter goes null in the middle of the operation. i.e., It deletes some records from the database as it is supposed to do, but then goes null.
Is there some way to query the database to get more information on why this is happening? Any debugging ideas? I don't have much experience with SQL Server, so if you have an idea please give me the specifics. Thanks.
|
|
|
|
|
First, I didn't quite understand what you mean with 'station'. However, I believe that it's hard to observe this situation from database since the reason most likely isn't in the database.
Instead, use debugger in Visual Studio, catch the exception immediately when it happens (use menu Debug/Exceptions... to catch all handled/unhandled exceptions) and then use breakpoints to narrow the area.
The most likely cause for this is that if you are reusing same data adapter, when the first operation ends and you perhaps dispose the object, you use the same variable somewhere else (or same code in another thread) and the value is set to null.
One way to get more information is to add diagnostics messages (for example using Trace.WriteLine) to every place where you instantiate the data adapter, set it to null (or dispose it, i.e. using blocks) or use it. This will give you info how things are going and in which order (especially if you're using threads).
Hope this helps,
Mika
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Thanks for the suggestions, Mika.
By station I meant client.
Via Debug/Exceptions is how null data adapter was determined.
Adapter is instantiated on startup and disposed of when application quits - isolated in one class. Pretty simple in that respect.
Agree it might be caused in some other area - since it happens sporadically and has been hard to pinpoint using the debugger, was just wanting to try another avenue. I was hoping the database might keep something like a 'last error' the way it tracks number of deadlocks.
Have found a way around it for the time being.
Thanks again ...
|
|
|
|
|
Okay,
Just for explanation: If the command would fail while in the database or connection gets lost for some reason, you end up in an error at the database. As a result of an error you would get an exception at calling side (in C# in this case). So, if you're not receiving any exceptions in your code, but the data adapter just suddenly goes to null, it's quite certain that the problem is in the code.
If you're using singleton or static class, perhaps one way to find out the problem is to define a property that returns your data adapter and keep the data adapter private in your class (if not already done so). Now in the property setter, first test if new value for the property is null and act based on that (throw an exception, write log etc). This could help you to isolate the cause.
Also you could double-check that you are not ignoring any exceptions anywhere. One reason could be that the statement actually fails in the database, but you don't get information about the exception (for example an empty catch block).
If you would end up in a deadlock you would get an exception in C# and have a message similar to:
"Transaction (Process ID 52) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction."
However, if you suspect that deadlock might occur, you can set trace flag 1204 in startup parameters. After restarting the SQL Server, deadlock info if is written into errorlog at server side if a deadlock occurs.
Hope this helps you forward,
Mika
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Thanks Mika,
It is the last bit about the trace flag that I was looking for. Setting it I believe requires access to the server machine which I don't have, but the person who does says they can help me do this next week and he thinks he knows how to set a trace.
Maybe more information than you are interested in, but since you put so much time in, don't want you to think I was ignoring your ideas. This was a situation of you have today to figure it out and then things are moving on and you need to be working on something else. Not to say it won't get revisited, but these are decisions made 'above' me. The null data adapter came about after code was introduced to allow for possible deadlock. It is most likely a case of interference/timing - something hasn't been thought through well enough for when multiple clients are running at the same time. Removing some functionality removed the deadlock problem and thus the need for the code that caused the null data adapter. Other people were looking into it from the C# side, and I was just asked to help if I could. I knew you could query the database for number of deadlocks and I had the permissions to do this. I thought if it was possible that the database could give any information, then it might at least be a clue for where to look.
Now I will know about the database trace flag - it will come in handy at some point. Thanks.
|
|
|
|
|
You're welcome
And I really appreciate that you took the time time answer. It's always good to know if a reply is helpful or not since we're all learning here
If you need assistance in the future, post a message and we'll try to help you.
Mika
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Look into threading problems (as Mika hinted).
Other than that, we may need to see your code.
|
|
|
|
|
PIEBALDconsult,
Please see my response to Mika, and yes, if it gets revisted and I am involved in the revisit, I will look at the threading and try to get it narrowed down more. The code sits on an isolated system and is too complicated to reproduce here. The data adapter code is quite simple, but I think we're all agreed that that's probably just where another problem is manifesting itself. Thanks for your input.
|
|
|
|
|
I have a SQL CE 3.5 database that I'm building on a server and downloading to a handheld. Before trying to open the database I'm calling SqlCeEngine.Verify. In my development environment, I rarely have this fail, and when I do it appears to be my fault. Our customers are now using this software, but they are experiencing an issue I cannot recreate.
Basically when the download completes, the verify is failing on the customers handhelds. Each time the verify fails, I redownload the database and try again. However, it seems that when the database finally does verify, I get;
Unspecified Error [sqlceqp35.dll]
Does anybody have any idea what this does? I've tried searching, and I've tried putting in more logging to get a more accurate idea of where this is occuring. But it seems to prevent the database from opening until the software is restarted.
|
|
|
|
|
Different version of the database. One solution I have seen is to manually create the DB on the handheld when the application starts rather than just copying the CE db. This allows the correct version to be used from the device standpoint. Really a PITA.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
There are two tables, NAMES (ID INT IDENTITY (1,1), NAME VARCHAR(255)) and
RELATIONSHIPS ( NAMEID INT , PARENT _ NAMEID INT ) linked via NAMES.ID = RELATIONSHIPS.NAMEID and where top-most name has a PARENT _ NAMEID = 0.
Show a nested list of names including LEVEL , NAMEID and NAME , where LEVEL indicates the nest level (or depth) from the top, as indicated in the expected output (below).
NAMES table content:
==================
ID NAME
1 Frank
2 Jo
3 Mary
4 Peter
5 Amy
RELATIONSHIPS table content:
==========================
NAMEID PARENT _ NAMEID
1 0
2 1
3 2
4 1
5 2
Expected Output:
===================
In the expected output, please note The sequence of the output, in which child elements appear immediately beneath their respective parent elements.
LEVEL ID NAME
0 1 Frank
1 2 Jo
2 5 Amy
2 3 Mary
1 4 Peter
any sounds please...
Ramana
|
|
|
|
|
This looks like a homework assignment.
First try and do it before you ask for help otherwise it defeats the purpose of it.
|
|
|
|
|
|
Dear All,
I need to enable xp_cmdshell in my dB server which is sql server 2000.
For doing that I run the following command on the machine where SQL server 2000 is installed with administrator privileges.
---- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
---- To update the currently configured value for advanced options.
RECONFIGURE
GO
---- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
When I run the third command to enable xp_cmdshell it gives me the following error:
Server: Msg 15123, Level 16, State 1, Procedure sp_configure, Line 78
The configuration option 'xp_cmdshell' does not exist, or it may be an advanced option.
Valid configuration options are:
But I know that xp_cmdshell is present, although it is not visible in Enterprise MAnager. When I run commands using that proc in Query Analyzer it gets executed, which means that it present somewhere.
Unless I enable this proc I cannot use it within another proc (wrapper proc) for calling it from my web application.
Pls provide step by step instructions.
Thanks in advance.
|
|
|
|
|
Perhaps the procedure was not disabled but rather removed from the dll, I have seen this done before. If I remember correctly this procedure is in xplog70.dll, perhaps try getting a copy of this dll from another server and overwrite your own(you will have to stop the SQL service), don't forget to make a backup.
|
|
|
|
|
But if it was removed from the dll how is it working in the Query Analyzer.
So clearly it is present somewhere in the server but my Application cannot access it since it is a non sysadmin user.
|
|
|
|
|
Try this:
In enterprise manager expand your master database and select "Extended Stored Procedures", scroll down to xp_cmdshell, right-click it and select properties. Click on the permissions button. Check if your user has rights.
|
|
|
|
|
IN MSSQL 2005 to Enable xp_cmdshell
Open SQL Server 2005 Surface Area Configuration
Click Surface Area Configuration for Features
Expand Database Engine
Select xp_cmdshell
Check Enable xp_cmdshell
click Apply, click OK
|
|
|
|
|
how to print
*
**
***
****
*****
using sql remember not by using pl/sql block......
thanks in advance....
|
|
|
|
|
Whats your problem, all I see is a request for a solution.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hey,im simply asking whether its possible to do it by simple sql program, if yes then answer it.
otherwise don't mind.
|
|
|
|
|
Oh sorry, then the answer is Yes it can be done.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hey cool man you can do that....we need to use lpad function and rownum to achive this.
Assuming emp table has more than 5 rows,
select lpad('*',rownum,'*') from emp where rownum<6
Read abt rownum in google
|
|
|
|