0

I have a database in my sql server and I also created one view in it to store a really long, I mean a really long query. And I need to use this query to fill a SqlDataAdapter in VB

Basic example with very straight easy query on how to fill a SqlDataAdapter

adapter.Fill("Select * from products")

I only wish my query was this simple and straight forward, instead i have a monster of a query and dont't want / cant't just paste it in my code. Isn't there another way to access it like so:

adapter.Fill(dataSet.ViewWithLongQuery)

The Dataset here contains my View

Thanks!

3
  • 1
    Can you call the view instead of the table name? Something like Select * FROM <myViewName>? Commented Jun 10, 2016 at 14:06
  • Yep it works as intented than you very much my friend Commented Jun 10, 2016 at 15:09
  • James - Glad that worked for you. I have posted the above comment as an answer. Commented Jun 10, 2016 at 15:16

1 Answer 1

2

This was posted as a question in a comment, so I will convert it to an answer. Select directly from the view.

Select * FROM <myViewName>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.