I have problem in sql query [Resolved]

Posted by Nuwan under ASP.NET on 8/9/2012 | Points: 10 | Views : 890 | Status : [Member] | Replies : 5
I write Sql query in Application.
this is my query "SELECT SUM(F_VAT) AS Amunt FROM MyTbl WHERE (CONTRACT ='hpky000292') AND (DUEDATE >= GETDATE())"

Some time run it get a null value.How I remove getting null value.
Please help me....

Rathnayake


Responses

Posted by: San.Pblr.Gct on: 8/9/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
SELECT Isnull(SUM(F_VAT),0) AS Amunt FROM MyTbl WHERE (CONTRACT ='hpky000292') AND (DUEDATE >= GETDATE())"

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jeena on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,


Can you explain a bit more about the requirement?
It will be good if you can share me the script ,sample data and a sample of your desired result


Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
Im Executing this query using Sqldatareader. after I get this value as a variable.In that some time Read a null value and getting error,
I want to handle this null value.


Rathnayake

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jeena on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Please try this

using (SqlConnection connection = new SqlConnection(strConn))
{
connection.Open();
using (SqlCommand command = new SqlCommand("your query", connection))
{
//
// Invoke ExecuteReader method.
//
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{

if(!reader.IsDBNull(1))
Title = reader.GetString(1); //1 is the index of column

}

}
}

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
Its work Great San.Pblr.Gct. thanks lot.


Rathnayake

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response