View Single Post
  #1 (permalink)  
Old 11-10-2008, 6:23 AM
wstevens wstevens is offline
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: May 2008
Location: South Africa PTA
Posts: 16
Reputation: 25
wstevens is on a distinguished programming path ahead
Default QueriesTableAdapter returning 0 value

Hi All

I have researched this problem and found info but none have proper solutions. I have a stored procedure. The stored procedure returns a value of 1 if the column exists in a specific table and 0 if not.

I created a QueriesTableAdapter in a Dataset telling it to use the existing stored procedure. I select it to return Single value.

If I test the query in dataset design by preview data it returns the required value correctly, however if I call it from VB.Net it always returns 0.

Here is my code

Code:
Dim scalarQueriesTableAdapter As DSMetricsTableAdapters.QueriesTableAdapter

        scalarQueriesTableAdapter = New DSMetricsTableAdapters.QueriesTableAdapter

        Dim returnValue As Integer

        returnValue = CType(scalarQueriesTableAdapter.CheckMetrics("Department", "tbl_Metrics"), Integer)

Here is my stored procedure

Code:
@ColumnName varchar(100),
@TableName varchar(100)

AS
	
IF EXISTS(SELECT 1 FROM Syscolumns WHERE NAME= @ColumnName AND id=OBJECT_ID(@TableName))
		
RETURN 1

Last edited by JohnH; 11-19-2008 at 6:38 PM. Reason: formatted post for readability
Reply With Quote