473,324 Members | 2,535 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,324 software developers and data experts.

Not retrieving values

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
10 1215
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
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
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
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
"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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Victor | last post by:
I'm retrieving values from the textboxes that I created dynamically. However I get commas appended to my text values and just a comma wherever the textbox is empty. Dont know what is causing this....
13
by: RHPT | last post by:
I am wanting to capture the XML posted by an InfoPath form with .NET, but I cannot figure out how to capture the XML stream sent back by the InfoPath form. With Classic ASP, I could just create an...
3
by: Dotnet Gruven | last post by:
I've built a WebForm with a Table added dynamically in Page_Load when IsPostBack is false. The table includes a couple of TextBoxes, RadioButtonLists and CheckboxLists. On postback, those...
0
by: Andy | last post by:
Hi All. I'm working for a company that has set out a guideline for retrieving data from a database. Nobody can explain to me the reason for the following. When retrieving a set of records...
1
by: Captain Dondo | last post by:
I am not really experienced in Javascript so bear with me.... I am working with an embedded platform; no mouse, no keyboard. Just up, down, left, right keys and +/- keys for...
0
by: Edward Clements | last post by:
This post is a followup to the thread "retrieving the XmlEnumAttribute values for an Enum" in this same forum earlier this month, since my last query in that thread went unanswered. I have an...
10
by: Girish | last post by:
Hi Everyone, I am passing a form to a php script for further processing. I am able to retrieve the last value set for that given form variable using $variable=$_REQUEST;
6
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList...
15
by: gunnar.sigurjonsson | last post by:
I´m having some problem retrieving identity value from my newly inserted row into a view. I have two tables T1 and T2 which I define as following CREATE TABLE T1 ( id BIGINT GENERATED ALWAYS...
5
by: Sanjay Pais | last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time using the with - over clauses In query analyser, the data is retrieved in under a second. When retrieving using the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.