|
Firstly you should post this in vb Forum,
Secondly your Code is messy, it seems you dont know where to put your code. You are Executing the command outside your connection. Open the Connection and Execute your command and Close the Connection and Close the reader and after that you dont need to loop through the reader. Here is my Suggestion, why dont you use a StoredProcedure that returns number of rows ,and when you call that Stored Procedure you will test for records that are returned. if you planned it well you will be looking for an integer that is "1" or less than one , e.g
if(intTeturned < 1)
{
}
else
{
}
}
Hope this Helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi,
I created a kind of employees application with all sorts of data. I working with SQL server and C#.
I have most string and int data, but also some images.
But i use the "string-with-path-method" to get to the images.
It works ok, but since the images are in a folder, it seems that they are not as private like the other data.
I dont know how to work with the images in SQL server, so i use that method.
Can anyone help me here?
Thanks
|
|
|
|
|
|
|
Hi,
I design a windows application that needs to pull data from a SQL server database.
It works just fine!!!.
But, when i install the application in another computer i get problems,I need to attach the database in SQL server in order to work.
So, i want to get a nice "connection string" to pull data from the database without no further "attachments"!
Can anyone help me?
(I usually use *.udl files to see the connection-string)
Thanks
modified on Wednesday, July 2, 2008 9:29 PM
|
|
|
|
|
Please do ODBC Connctivity. did you know any thing about that?
You should first define a ODBC connectivity in your Projects. After that first you establish ODBC Connection in your client system, after install your exe in the particular system, it will work definately.
|
|
|
|
|
ODBC will require that you establish an ODBC connection from the client - therefore you need to manage the client as well as your app.
I suggest this site
clickety[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Any idea how to create an SID for the oracle instant client??
Many thanks
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
|
|
HI,
i am dealing with a database, which is having billions of data. To improve the performance have introduced threads( thread pool c#). Also implemented locks to avoid conflict. But unfortunately that didnt improved the performance.
I did the same without lock now i got 25% improvement...
Tell me an idea to achieve performance without conflict
My small attempt...
|
|
|
|
|
Is the database normalized? Have you checked queries with query analyzer for bottlenecks? Those would be the first things I'd look at.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
the database is normalized.... doing indexing every weekend...
will check the queries to find bottlenecks...
do you have anyidea what happened to my threading ?
My small attempt...
|
|
|
|
|
sujithkumarsl wrote: Also implemented locks to avoid conflict. But unfortunately that didn't improved the performance.
How you did it ? Please post sample code so we can check what happened with your threading.
|
|
|
|
|
hi,
check this...
WaitHandle[] resetEvents = new WaitHandle[GeCommonConfig.ThreadCount];
for (int index = 0; index < GeCommonConfig.ThreadCount; index++)
{
resetEvents[index] = new AutoResetEvent(false);
ThreadDetails objThreaddetails = new ThreadDetails((AutoResetEvent)resetEvents[index], index.ToString());
ThreadPool.QueueUserWorkItem(new WaitCallback(StartProcessing), objThreaddetails);
}
WaitHandle.WaitAll(resetEvents);
Here StartProcessing is the method.... in which 80 datatables have been updating...among some are having billions of data...
protected static bool ExecuteQuery(string strQuery, DataSet dataSet, Object lockObject)
{
try
{
lock (lockObject)
{
return ExecuteQueryEx(strQuery, dataSet);
}
}
catch
{
}
return false;
}
I have a LockType class in which defined 5 differnt lock objects. according to the query( which all tables are using) the lock is passing to the ExecuteQuery method..
My small attempt...
|
|
|
|
|
sujithkumarsl wrote: WaitHandle.WaitAll(resetEvents);
This blocks the caller thread till all threads you queued finished executing. If it blocks, I don't see the benefit of using threading here. Your design is confusing. Can you post sample of the "StartProcessing" method ? Are you on a stand alone application or a web application ?
|
|
|
|
|
WaitHandle.WaitAll(resetEvents); just make sure that all threads completed.... main thread will wait there no problem..
here Startprocessing will do all the Database operations ( will run in different threads)
its windows application..
startProcessing()
{
Heavy Databse operations are doing here ( including insert, delete, select, update)
executeQuery();
}
My small attempt...
|
|
|
|
|
Are your clustered indexes being used?
Usually having the correct clustered indexes help a lot, but if they are build wrong for the tables, then your going to have overhead (long query times, more space being taken up).
If your using SQL Server, then the "Estimated Execution Plan" in the SQL Management Stuido can help a lot with seeing the steps of the queries and what operations are taking the longest to complete.
|
|
|
|
|
a couple more ideas
Partitioning your data
Striping your tables across multiple disks
And of course index tuning
Then check your queries and the join/where clauses
Hire a DBA to do some performance tuning (if tables have "billions" of rows you need one)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi i have tested the application in a better machine( 32 GB ram, 16 processors) with 8 threads and finally i got 355% improvements.
anyway i am planning to have a small database for all operations and end of the day i will deploy the values to the main database.. what you think
My small attempt...
|
|
|
|
|
I need help on creating a trigger for insert and update. My table looks like this:
tblCandidates
canID smallint PK identity
ID int FK
eleID smallint FK
What I need to do is: During insert or update, if there are two records with the same ID and eleID, operation should be aborted and to return some string as output (ex: "operation impossible")
Thank you
|
|
|
|
|
Why not include eleID in primary key?
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
I don't think a trigger works like that. As I never use triggers this is conjecture
Insert/Update causes trigger to execute, the trigger is a seperate stored procedure and cannot affect the outcome of whatever causes the insert/update.
However:
You really should put this check in the initial method, otherwise you are programming by error. IE try something if there is an error then it is wrong ahh do something else.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Easiest way to do this is by creating an unique non-clustered index (it could be clustered, but since there is a PK on the table a clustered index should have been created by default as the PK columns):
Create unique nonclustered index IX_Id_eleID on <table_name>
(
Id
,eleId
)
When duplicate rows are inserted, it will give the following error:
Msg 2601, Level 14, State 1, Line 1
Cannot insert duplicate key row in object 'dbo.cTest' with unique index 'IX_Id_eleID'.
Just put the name of the table in place of <table_name>, and name the index how you want.
|
|
|
|
|
Scott
While this works and is probably the correct solution it is still "programming by error" and you have an additional constraint on the table to support sloppy development.
I would do the check BEFORE attempting to insert/update the record, this may entail an additional index so it may nullify the constraint argument.
Never underestimate the power of human stupidity
RAH
|
|
|
|