473,385 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

form close

int active = 0;

conn = new SqlConnection (sConn);
conn.Open() ;
SqlCommand sc = new SqlCommand ("LogoActiveCheck",conn);
sc.CommandType = CommandType.StoredProcedure;
sc.Parameters.Add (
new SqlParameter ("@RowCount",ParameterDirection.ReturnValue));
sc.ExecuteNonQuery();
sc.Connection.Close ();
active = (int)sc.Parameters["@RowCount"].Value;
I'm using this code to get @rowcount, but when it finishes form closes.
Why?

Hrcko
Nov 17 '05 #1
3 1177
"Hrcko" <hr*********@luatech.com> wrote in message
news:dk**********@ss405.t-com.hr...
int active = 0;

conn = new SqlConnection (sConn);
conn.Open() ;
SqlCommand sc = new SqlCommand ("LogoActiveCheck",conn);
sc.CommandType = CommandType.StoredProcedure;
sc.Parameters.Add (
new SqlParameter ("@RowCount",ParameterDirection.ReturnValue));
sc.ExecuteNonQuery();
sc.Connection.Close ();
active = (int)sc.Parameters["@RowCount"].Value;

I'm using this code to get @rowcount, but when it finishes form closes.
Why?

Hrcko


You need to keep the connection open until you have read the parameter. You
are getting an exception which is ending up terminating the app
Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Nov 17 '05 #2
I put a variable active after ExecuteNonQuery, but it closes when
Execute NonQuery is finished.

Hrcko

Richard Blewett [DevelopMentor] wrote:
"Hrcko" <hr*********@luatech.com> wrote in message
news:dk**********@ss405.t-com.hr...
int active = 0;

conn = new SqlConnection (sConn);
conn.Open() ;
SqlCommand sc = new SqlCommand ("LogoActiveCheck",conn);
sc.CommandType = CommandType.StoredProcedure;
sc.Parameters.Add (
new SqlParameter ("@RowCount",ParameterDirection.ReturnValue));
sc.ExecuteNonQuery();
sc.Connection.Close ();
active = (int)sc.Parameters["@RowCount"].Value;

I'm using this code to get @rowcount, but when it finishes form closes.
Why?

Hrcko

You need to keep the connection open until you have read the parameter. You
are getting an exception which is ending up terminating the app
Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Nov 17 '05 #3
Hi,

Where this piece of code is located?

Are you getting any exception?

Set the debugger to "break on exception" to see if you are getting some
exception
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Hrcko" <hr*********@luatech.com> wrote in message
news:dk**********@ss405.t-com.hr...
I put a variable active after ExecuteNonQuery, but it closes when Execute
NonQuery is finished.

Hrcko

Richard Blewett [DevelopMentor] wrote:
"Hrcko" <hr*********@luatech.com> wrote in message
news:dk**********@ss405.t-com.hr...
int active = 0;

conn = new SqlConnection (sConn);
conn.Open() ;
SqlCommand sc = new SqlCommand ("LogoActiveCheck",conn);
sc.CommandType = CommandType.StoredProcedure;
sc.Parameters.Add (
new SqlParameter ("@RowCount",ParameterDirection.ReturnValue));
sc.ExecuteNonQuery();
sc.Connection.Close ();
active = (int)sc.Parameters["@RowCount"].Value;

I'm using this code to get @rowcount, but when it finishes form closes.
Why?

Hrcko

You need to keep the connection open until you have read the parameter.
You are getting an exception which is ending up terminating the app
Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
11
by: Zytan | last post by:
I have created a new form from the main form. When I close the main form with the 'x' close button, its Form.FormClosed event is run, but not the dialog's. Is this normal? It is ok /...
5
by: pbhandari | last post by:
Hi, I have following line in my Perl code--> system("start my.exe myfile.ext") == 0 or die "error ($?) : $!"; Q1: How do I close my.exe? Q2: If I give myfile.ex1 instead of myfile.ext,...
9
by: dombrost | last post by:
Hi all. I am total newbie to Access so any help is greatly appreciated. I am creating a simple database in Access 2003 that captures details of an operation event. I created a form for the user...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.