After working on my database a bit, I am working on a VB.Net app that accesses it using LINQ. I have the following stored procedure in the database:
CREATE PROCEDURE dbo.GetTableColumn( @ColName VARCHAR(MAX), @TblName VARCHAR(MAX), @Result BIT OUT ) AS BEGIN IF (EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @TblName AND COLUMN_NAME = @ColName)) BEGIN DECLARE @SQL VARCHAR(MAX) SET @SQL = 'SELECT ' + @ColName + ' FROM ' + @TblName EXEC (@SQL) SET @Result = 1 END ELSE SET @RESULT = 0 RETURN @Result END
I have added it to my DataLINQContext and call it in the following method in my VB.Net code:
Public Function GetTableColumn(ByVal col As String, ByVal table As String) As AutoCompleteStringCollection GetTableColumn = New AutoCompleteStringCollection Using dbContext As New Customer_LINQDataContext Dim result As Boolean Dim query = dbContext.GetTableColumn(col, table, result) MessageBox.Show(query.ToString()) End Using End Function
Now what I am trying to accomplish, is that the query object receives the data from the query performed by the procedure. This does not happen. Instead I only get a 1 or 0 result, based off whether or not the column exists within the table.
So obviously something is wrong somewhere. I feel it's a mess up on the part of my procedure, but I am not sure how to code it to accomplish what I want it to do.