Calling a stored procedure from 2 ppc's at the same time

T

Tomer

Hi,
I've wrote a ppc app that connects to a sql server on a remote pc using RF
connection.
After I connect, in a certain moment in the application I call a stored
procedure that run a DTS.
This work just fine when I use one pocket pc.
But when I bring up a second PPC, the troubles begins.
First thing, when I'm running the stored procedure not at the same time from
the two ppc's everything is ok.
But when I simultaneously run the stored procedure one call goes well and
the other gives an exception.
I've also tried login in to the sql server, with the second ppc, with a
different user

Any help?

Tomer.
 
J

John Kuczynski

Tomer,

What exception is thrown? Perhaps knowing that will help us to determine
what is going on...

Does the same exception occur when running the SP twice from two desktops?

Most likely a SQL issue rather than something specific to PPC or CF.

-John
Issentia, Inc.
 
T

Tomer

Ok,
I've tried this creating two stored procedures (sp_AddRow1,sp_AddRow2) which
are the same and contain this code:

CREATE PROCEDURE [dbo].[sp_AddRow1]
@ThePhone varchar (10)
AS
Insert Into Models (Code) Values (@ThePhone)
GO

Then I've made a test application that would run on two ppc, and run in a
loop the stored procedures. ppc number 1 would run sp_AddRow1 and ppc number
2 would run sp_AddRow2.

when the two ppc's running togther after a while one of them stops and after
a while gives this exception : "General network error. Check your network
documentation." The other one continues and finishes the loop.
This doesn't happens right away and not after the same time period.

Here's the c# code:

SqlConnection Conn = new SqlConnection("Server=TOMER;Database=TestWH;user
id=sa;password=sa");

Conn.Open();

SqlCommand Cmd = new SqlCommand("sp_AddRow" + textBox2.Text,Conn);

Cmd.CommandType = CommandType.StoredProcedure;

Cmd.Parameters.Add("@ThePhone",SqlDbType.Text);

for (int i=0;i<100;i++)

{

try

{

Cmd.Parameters[0].Value = textBox1.Text;

textBox1.Text = (int.Parse(textBox1.Text)+1).ToString();

Cmd.ExecuteNonQuery();

Thread.Sleep(200);

}

catch (SqlException ex)

{

MessageBox.Show(ex.Message,ex.Source);

}

}
 
T

Tomer

Problem solved! Its was a network configuration problem, nothing to do with
ppc or dot net!


Tomer said:
Ok,
I've tried this creating two stored procedures (sp_AddRow1,sp_AddRow2) which
are the same and contain this code:

CREATE PROCEDURE [dbo].[sp_AddRow1]
@ThePhone varchar (10)
AS
Insert Into Models (Code) Values (@ThePhone)
GO

Then I've made a test application that would run on two ppc, and run in a
loop the stored procedures. ppc number 1 would run sp_AddRow1 and ppc number
2 would run sp_AddRow2.

when the two ppc's running togther after a while one of them stops and after
a while gives this exception : "General network error. Check your network
documentation." The other one continues and finishes the loop.
This doesn't happens right away and not after the same time period.

Here's the c# code:

SqlConnection Conn = new SqlConnection("Server=TOMER;Database=TestWH;user
id=sa;password=sa");

Conn.Open();

SqlCommand Cmd = new SqlCommand("sp_AddRow" + textBox2.Text,Conn);

Cmd.CommandType = CommandType.StoredProcedure;

Cmd.Parameters.Add("@ThePhone",SqlDbType.Text);

for (int i=0;i<100;i++)

{

try

{

Cmd.Parameters[0].Value = textBox1.Text;

textBox1.Text = (int.Parse(textBox1.Text)+1).ToString();

Cmd.ExecuteNonQuery();

Thread.Sleep(200);

}

catch (SqlException ex)

{

MessageBox.Show(ex.Message,ex.Source);

}

}







John Kuczynski said:
Tomer,

What exception is thrown? Perhaps knowing that will help us to determine
what is going on...

Does the same exception occur when running the SP twice from two desktops?

Most likely a SQL issue rather than something specific to PPC or CF.

-John
Issentia, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top