D
DeepHalo
I want to do simply this in MS Access.
PARAMETERS pTableName;
SELECT * FROM pTableName;
This doesn't work ( if it did I wouldn't ask you ) but is it clear
what I want to do? Just with passing table names or columns as
parameters I want to change my query but not using any programming
language as Java, VB, C# ... Just like Stored Procedure in SQL Server I
want to create this query and call it from my proc.
-----
Here is my SQL Server SP:
CREATE PROCEDURE MyQuery @TABLENAME VARCHAR(10) AS EXEC('SELECT * FROM
' + @TABLENAME + '')
and the function I use with it:
Private Function RunQuery(ByVal tableName As String) As DataTable
Dim da As IDbDataAdapter
Dim cmd As IDbCommand
Dim ds As New DataSet
Dim dt As DataTable
Try
cmd = myDataProvider.ERCommand("MyQuery")
cmd.Connection = myDataProvider.ERConnection
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(myDataProvider.ERParameter("TABLENAME"))
cmd.Parameters(0).Value = tableName
da = myDataProvider.ERDataAdapter
da.SelectCommand = cmd
da.Fill(ds)
dt = ds.Tables(0)
RunQuery= dt
Catch ex As Exception
Call ErrorControl(ex, "Error:RunQuery")
Finally
da = Nothing
cmd = Nothing
ds = Nothing
End Try
End Function
It works with SQL Server but not with access I don't want to put
another line of code here. I want to do all in my "defined query" in MS
Access. Is there a way?
PARAMETERS pTableName;
SELECT * FROM pTableName;
This doesn't work ( if it did I wouldn't ask you ) but is it clear
what I want to do? Just with passing table names or columns as
parameters I want to change my query but not using any programming
language as Java, VB, C# ... Just like Stored Procedure in SQL Server I
want to create this query and call it from my proc.
-----
Here is my SQL Server SP:
CREATE PROCEDURE MyQuery @TABLENAME VARCHAR(10) AS EXEC('SELECT * FROM
' + @TABLENAME + '')
and the function I use with it:
Private Function RunQuery(ByVal tableName As String) As DataTable
Dim da As IDbDataAdapter
Dim cmd As IDbCommand
Dim ds As New DataSet
Dim dt As DataTable
Try
cmd = myDataProvider.ERCommand("MyQuery")
cmd.Connection = myDataProvider.ERConnection
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(myDataProvider.ERParameter("TABLENAME"))
cmd.Parameters(0).Value = tableName
da = myDataProvider.ERDataAdapter
da.SelectCommand = cmd
da.Fill(ds)
dt = ds.Tables(0)
RunQuery= dt
Catch ex As Exception
Call ErrorControl(ex, "Error:RunQuery")
Finally
da = Nothing
cmd = Nothing
ds = Nothing
End Try
End Function
It works with SQL Server but not with access I don't want to put
another line of code here. I want to do all in my "defined query" in MS
Access. Is there a way?