By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,158 Members | 1,385 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,158 IT Pros & Developers. It's quick & easy.

Not retrieving values

P: n/a
Hi All,

I am facing a very peculiar problem, I am executing a stored procedure
residing in the Sybase database. When I do execute the Stored
Procedure from SQL Advantage I can retrexecve the values, but when I
execute the same from the .net code (VS.net 2003 C sharp) with the
same set of parameters I don't retrieve any values. Please help me
figure out the same.

Thanks in advance,
Nishanth

Feb 2 '07 #1
Share this Question
Share on Google+
10 Replies


P: n/a
It would be easier to figure out what was wrong if you posted the code you
are using to retrieve the data.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
------------------------------------------------
"Nishanth" <ra**********@gmail.comwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
Hi All,

I am facing a very peculiar problem, I am executing a stored procedure
residing in the Sybase database. When I do execute the Stored
Procedure from SQL Advantage I can retrexecve the values, but when I
execute the same from the .net code (VS.net 2003 C sharp) with the
same set of parameters I don't retrieve any values. Please help me
figure out the same.

Thanks in advance,
Nishanth

Feb 2 '07 #2

P: n/a
This is the code that is used to directly connect to the db

private void CallSp()
{
DataSet dsProject = new DataSet() ;
string startDate = "06/21/2002" ;
string EndDate = "";
string AccountType = "A";

string UserId = "" ;
string strMess = "";

try
{
string constr = string.Empty;
constr = "Provider=Sybase.ASEOLEDBProvider.2;Initial
Catalog=testdb;Password=testpass;User ID=testuser;Data
Source=IISS;Persist Security Info=True;";

OleDbConnection conn = new OleDbConnection(constr);

if(conn.State != ConnectionState.Open)
conn.Open();

OleDbCommand adptComm = new
OleDbCommand("sp_crm_top_holding",conn);
adptComm.CommandType = CommandType.StoredProcedure;
OleDbParameter parameter = adptComm.Parameters.Add(
"@from_date", OleDbType.VarChar);
parameter.Value = startDate ;

parameter = adptComm.Parameters.Add(
"@to_date", OleDbType.VarChar);
parameter.Value = EndDate ;

parameter = adptComm.Parameters.Add(
"@acct_type", OleDbType.VarChar);
parameter.Value = AccountType ;

parameter = adptComm.Parameters.Add(
"@username", OleDbType.VarChar);
parameter.Value = UserId ;

parameter = adptComm.Parameters.Add(
"@messagenet_num", OleDbType.VarChar);
parameter.Value = strMess ;

OleDbDataAdapter adpt=new OleDbDataAdapter(adptComm);

adpt.Fill(dsProject);
conn.Close();
Response.Write(dsProject.Tables[0].Rows.Count);

}
catch(Exception ex)
{
Response.Write(ex.Message) ;
}

}
Feb 5 '07 #3

P: n/a
Okayu, I don't see any obvious reasons that wouldn't work.

Have you managed to read from the Sybase database using .Net at all?

Robin S.
--------------------------------------------------
"Nishanth" <ra**********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
This is the code that is used to directly connect to the db

private void CallSp()
{
DataSet dsProject = new DataSet() ;
string startDate = "06/21/2002" ;
string EndDate = "";
string AccountType = "A";

string UserId = "" ;
string strMess = "";

try
{
string constr = string.Empty;
constr = "Provider=Sybase.ASEOLEDBProvider.2;Initial
Catalog=testdb;Password=testpass;User ID=testuser;Data
Source=IISS;Persist Security Info=True;";

OleDbConnection conn = new OleDbConnection(constr);

if(conn.State != ConnectionState.Open)
conn.Open();

OleDbCommand adptComm = new
OleDbCommand("sp_crm_top_holding",conn);
adptComm.CommandType = CommandType.StoredProcedure;
OleDbParameter parameter = adptComm.Parameters.Add(
"@from_date", OleDbType.VarChar);
parameter.Value = startDate ;

parameter = adptComm.Parameters.Add(
"@to_date", OleDbType.VarChar);
parameter.Value = EndDate ;

parameter = adptComm.Parameters.Add(
"@acct_type", OleDbType.VarChar);
parameter.Value = AccountType ;

parameter = adptComm.Parameters.Add(
"@username", OleDbType.VarChar);
parameter.Value = UserId ;

parameter = adptComm.Parameters.Add(
"@messagenet_num", OleDbType.VarChar);
parameter.Value = strMess ;

OleDbDataAdapter adpt=new OleDbDataAdapter(adptComm);

adpt.Fill(dsProject);
conn.Close();
Response.Write(dsProject.Tables[0].Rows.Count);

}
catch(Exception ex)
{
Response.Write(ex.Message) ;
}

}


Feb 6 '07 #4

P: n/a
On Feb 6, 6:10 am, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Okayu, I don't see any obvious reasons that wouldn't work.

Have you managed to read from the Sybase database using .Net at all?

Robin S.
--------------------------------------------------"Nishanth" <rao.nisha...@gmail.comwrote in message

news:11**********************@v33g2000cwv.googlegr oups.com...
This is the code that is used to directly connect to the db
private void CallSp()
{
DataSet dsProject = new DataSet() ;
string startDate = "06/21/2002" ;
string EndDate = "";
string AccountType = "A";
string UserId = "" ;
string strMess = "";
try
{
string constr = string.Empty;
constr = "Provider=Sybase.ASEOLEDBProvider.2;Initial
Catalog=testdb;Password=testpass;User ID=testuser;Data
Source=IISS;Persist Security Info=True;";
OleDbConnection conn = new OleDbConnection(constr);
if(conn.State != ConnectionState.Open)
conn.Open();
OleDbCommand adptComm = new
OleDbCommand("sp_crm_top_holding",conn);
adptComm.CommandType = CommandType.StoredProcedure;
OleDbParameter parameter = adptComm.Parameters.Add(
"@from_date", OleDbType.VarChar);
parameter.Value = startDate ;
parameter = adptComm.Parameters.Add(
"@to_date", OleDbType.VarChar);
parameter.Value = EndDate ;
parameter = adptComm.Parameters.Add(
"@acct_type", OleDbType.VarChar);
parameter.Value = AccountType ;
parameter = adptComm.Parameters.Add(
"@username", OleDbType.VarChar);
parameter.Value = UserId ;
parameter = adptComm.Parameters.Add(
"@messagenet_num", OleDbType.VarChar);
parameter.Value = strMess ;
OleDbDataAdapter adpt=new OleDbDataAdapter(adptComm);
adpt.Fill(dsProject);
conn.Close();
Response.Write(dsProject.Tables[0].Rows.Count);
}
catch(Exception ex)
{
Response.Write(ex.Message) ;
}
}
Nope this is the first time I am using Sybase database with .Net. I
think it has to something with Null strings that are being passed as
parameters to the database.

Nishanth.

Feb 9 '07 #5

P: n/a
"Nishanth" <ra**********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
On Feb 6, 6:10 am, "RobinS" <Rob...@NoSpam.yah.nonewrote:
>Okayu, I don't see any obvious reasons that wouldn't work.

Have you managed to read from the Sybase database using .Net at all?

Robin S.
--------------------------------------------------"Nishanth"
<rao.nisha...@gmail.comwrote in message

news:11**********************@v33g2000cwv.googleg roups.com...
This is the code that is used to directly connect to the db
private void CallSp()
{
DataSet dsProject = new DataSet() ;
string startDate = "06/21/2002" ;
string EndDate = "";
string AccountType = "A";
string UserId = "" ;
string strMess = "";
try
{
string constr = string.Empty;
constr = "Provider=Sybase.ASEOLEDBProvider.2;Initial
Catalog=testdb;Password=testpass;User ID=testuser;Data
Source=IISS;Persist Security Info=True;";
OleDbConnection conn = new OleDbConnection(constr);
if(conn.State != ConnectionState.Open)
conn.Open();
OleDbCommand adptComm = new
OleDbCommand("sp_crm_top_holding",conn);
adptComm.CommandType = CommandType.StoredProcedure;
OleDbParameter parameter = adptComm.Parameters.Add(
"@from_date", OleDbType.VarChar);
parameter.Value = startDate ;
parameter = adptComm.Parameters.Add(
"@to_date", OleDbType.VarChar);
parameter.Value = EndDate ;
parameter = adptComm.Parameters.Add(
"@acct_type", OleDbType.VarChar);
parameter.Value = AccountType ;
parameter = adptComm.Parameters.Add(
"@username", OleDbType.VarChar);
parameter.Value = UserId ;
parameter = adptComm.Parameters.Add(
"@messagenet_num", OleDbType.VarChar);
parameter.Value = strMess ;
OleDbDataAdapter adpt=new OleDbDataAdapter(adptComm);
adpt.Fill(dsProject);
conn.Close();
Response.Write(dsProject.Tables[0].Rows.Count);
}
catch(Exception ex)
{
Response.Write(ex.Message) ;
}
}

Nope this is the first time I am using Sybase database with .Net. I
think it has to something with Null strings that are being passed as
parameters to the database.

Nishanth.
Have you considered passing those empty strings as DBNull.Value instead?

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
Feb 10 '07 #6

P: n/a
On Feb 10, 5:25 am, "RobinS" <Rob...@NoSpam.yah.nonewrote:
"Nishanth" <rao.nisha...@gmail.comwrote in message

news:11**********************@v33g2000cwv.googlegr oups.com...
On Feb 6, 6:10 am, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Okayu, I don't see any obvious reasons that wouldn't work.
Have you managed to read from the Sybase database using .Net at all?
Robin S.
--------------------------------------------------"Nishanth"
<rao.nisha...@gmail.comwrote in message
>news:11**********************@v33g2000cwv.googleg roups.com...
This is the code that is used to directly connect to the db
private void CallSp()
{
DataSet dsProject = new DataSet() ;
string startDate = "06/21/2002" ;
string EndDate = "";
string AccountType = "A";
string UserId = "" ;
string strMess = "";
try
{
string constr = string.Empty;
constr = "Provider=Sybase.ASEOLEDBProvider.2;Initial
Catalog=testdb;Password=testpass;User ID=testuser;Data
Source=IISS;Persist Security Info=True;";
OleDbConnection conn = new OleDbConnection(constr);
if(conn.State != ConnectionState.Open)
conn.Open();
OleDbCommand adptComm = new
OleDbCommand("sp_crm_top_holding",conn);
adptComm.CommandType = CommandType.StoredProcedure;
OleDbParameter parameter = adptComm.Parameters.Add(
"@from_date", OleDbType.VarChar);
parameter.Value = startDate ;
parameter = adptComm.Parameters.Add(
"@to_date", OleDbType.VarChar);
parameter.Value = EndDate ;
parameter = adptComm.Parameters.Add(
"@acct_type", OleDbType.VarChar);
parameter.Value = AccountType ;
parameter = adptComm.Parameters.Add(
"@username", OleDbType.VarChar);
parameter.Value = UserId ;
parameter = adptComm.Parameters.Add(
"@messagenet_num", OleDbType.VarChar);
parameter.Value = strMess ;
OleDbDataAdapter adpt=new OleDbDataAdapter(adptComm);
adpt.Fill(dsProject);
conn.Close();
Response.Write(dsProject.Tables[0].Rows.Count);
}
catch(Exception ex)
{
Response.Write(ex.Message) ;
}
}
Nope this is the first time I am using Sybase database with .Net. I
think it has to something with Null strings that are being passed as
parameters to the database.
Nishanth.

Have you considered passing those empty strings as DBNull.Value instead?

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
Yes and still no success.. I am still not able to figure out the
solution for this problem.

Feb 13 '07 #7

P: n/a
While, I havent worked with Sybase - is there something like "sql
profiler", which tells you what sql statements are being executed
against any DB?
This will help determine, how the stored procedure is called. You
might need to check that & find where the problem could be

Hope this helps
Kalpesh

Feb 13 '07 #8

P: n/a
On Feb 13, 7:25 pm, "Kalpesh" <shahkalp...@gmail.comwrote:
While, I havent worked with Sybase - is there something like "sql
profiler", which tells you what sql statements are being executed
against any DB?
This will help determine, how the stored procedure is called. You
might need to check that & find where the problem could be

Hope this helps
Kalpesh
Kalpesh, if you find out about the same please do let me know, that
also will be of great help in trying to know how the sp is called and
the parameters being passed to the db can be found out.

Feb 16 '07 #9

P: n/a
Hey

From what I could figure out from a quick look at your code is that
although you have added the parameters to the Command object, you set
its value after adding it. I m not sure (since I do not have VS.Net
right now to check) but i think you should add the value to the
parameters and then add it.

with regards,
J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Feb 16 '07 #10

P: n/a
That's a good catch! I bet that *is* his problem.

Robin S.
-----------------------------
"Ravichandran J.V." <jv************@yahoo.comwrote in message
news:O7**************@TK2MSFTNGP05.phx.gbl...
Hey

From what I could figure out from a quick look at your code is that
although you have added the parameters to the Command object, you set
its value after adding it. I m not sure (since I do not have VS.Net
right now to check) but i think you should add the value to the
parameters and then add it.

with regards,
J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***

Feb 16 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.