I need to create a dynamic query using the tables belonging to different schemas in SQL sever 2008 R2. I used the following function to get datatable. It looks like the ASP.NET does not recognize the database schema. The error I got is Invalid object name
'Finance.HospitalAccount'.
How to create a query from tables in different schemas is my question. I am using VS 2010.
Shared Function GetDataTable(ByVal strQry As String) As DataTable
Dim strconn As String = System.Configuration.ConfigurationManager.ConnectionStrings("QOM_QualityConnectionString").ToString
Dim conn As SqlConnection = New SqlConnection(strconn)
Dim strError As String = ""
Dim objCmd As New SqlCommand
objCmd.Connection = conn
objCmd.CommandType = CommandType.Text
Dim objDS As New DataSet
Dim objDT As New DataTable
Try
' Create new DataAdapter
...
Go to the complete details ...