Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

loop to get data from sql

Posted on 2003-11-19
9
Medium Priority
?
311 Views
Last Modified: 2010-04-16
Hi,
I want to have function will wait for the row has been release from SQL. It is still lock then I need to have loop to check every 10 seconds with through exception.
Thanks!
jpc
0
Comment
Question by:jpchen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 7

Accepted Solution

by:
jj819430 earned 375 total points
ID: 9787814
public SqlDataAdapter Connection(string SqlStatement)
            {
                  SqlConnection myConnection = new SqlConnection("server=(local);uid=****;pwd=*****;database=DatabaseName;");
                  SqlDataAdapter myCommand = new SqlDataAdapter(SqlStatement, myConnection);
                  return myCommand;
}
// Connection takes in a string that is what you are searching for

public int SqlRowCheck(string SqlQuestion)
            {
                  SqlConnection myConnection = new SqlConnection("");
                  SqlDataAdapter myCommand = new SqlDataAdapter(SqlQuestion,myConnection);
                  DataSet Check = new DataSet();
                  myCommand.Fill(Check,"TABLE NAME");
                  return Convert.ToInt32(Check.Tables["TABLE NAME"].Rows[0][0]);
            }

// this assumes that you are locking with just an int value on the table. Without a better knowledge of how your design is set I can't get a more specific answer

in a function call this.

int Locked = 1;
while(locked != 0)
{
locked = SqlRowCheck(YourSearchString)
// delay can be done if you want.
}

SqlDataAdapter Connection(string SqlStatement);
0
 

Author Comment

by:jpchen
ID: 9788372
if I setting up the timeout in the connection string, how to handle the time out issue?
0
 
LVL 7

Expert Comment

by:jj819430
ID: 9788430
http://www.codeproject.com/csharp/timeralarm.asp

This link can show you how to build a solid timer
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:jpchen
ID: 9788489
I don't want to use other timer, I rember there is timeout value you can add to the connection string, but how to handle the timeout issue, there is what i am not sure what to do it.
Thanks!
jpc
0
 
LVL 7

Expert Comment

by:jj819430
ID: 9788533
to set the timeout on the connection string
myConnection.ConnectionTimeout = TheAmountOfTime;
0
 

Author Comment

by:jpchen
ID: 9788610
thanks, but how to handle after timout?
0
 
LVL 7

Expert Comment

by:jj819430
ID: 9788645
SqlException is what I think it throws.

so do this.
try{

blah blah blah

}
catch(SqlException error)

then you can catch and handle the exception right there. Your app will know it failed. if it fails have it loop.
0
 

Author Comment

by:jpchen
ID: 9792094
Thanks,  but how can I just catch the timeout error, I don't want to loop with other SQL issue.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question