I'm having a real brain fart on this. I know how to use variables for column values in an sql statement in ASP.Net 2.0 but how do I word the function if the table name is the variable?
Public Shared Function GetSQLTQResults(ByVal strtablename As String) As DataTable
Dim strCon As String = GetConnectionString("FMC_ACCESSConnectionString")
Dim conn As New SqlConnection(strCon)
Dim cmdSelect As New SqlCommand("SELECT Convert(varchar(10),tablename.Date,101) As Date,tablename.Result As Result,tablename.Test As Test FROM tablename Where tablename = @tablename ", conn)
cmdSelect.Parameters.Add("@tablename", SqlDbType.NVarChar, 20).Value = strtablename
Dim dtrTable As New DataTable
conn.Open()
dtrTable.Load(cmdSelect.ExecuteReader(CommandBehavior.CloseConnection))
Return dtrTable
End Function
??
Public Shared Function GetSQLTQResults(ByVal strtablename As String) As DataTable
Dim strCon As String = GetConnectionString("FMC_ACCESSConnectionString")
Dim conn As New SqlConnection(strCon)
Dim cmdSelect As New SqlCommand("SELECT Convert(varchar(10),tablename.Date,101) As Date,tablename.Result As Result,tablename.Test As Test FROM tablename Where tablename = @tablename ", conn)
cmdSelect.Parameters.Add("@tablename", SqlDbType.NVarChar, 20).Value = strtablename
Dim dtrTable As New DataTable
conn.Open()
dtrTable.Load(cmdSelect.ExecuteReader(CommandBehavior.CloseConnection))
Return dtrTable
End Function
??