Public Shared Function GetData(ByVal ConnectionStr As String, ByVal SQL As String, ByVal TableName As String)
Dim connection As New SqlClient.SqlConnection
Dim dsSQL As New DataSet(TableName)
connection.ConnectionString = ConnectionStr
Try
connection.Open()
Dim daSQL As New SqlClient.SqlDataAdapter(SQL,connection)
daSQL.FillSchema(dsSQL, SchemaType.Source, TableName)
daSQL.MissingSchemaAction = MissingSchemaAction.AddWithKey
daSQL.Fill(dsSQL, TableName)
Catch ex As Exception
MsgBox(ex.ToString)
Finally
connection.Close()
End Try
Return dsSQL
End Function
|