Wednesday, March 28, 2012

Saving Queries

I just started using Visual Studio 2005. How do you actually save your queries to use again? Also, is there a way to export results in a user friendly format?

thanks!

Not quite sure what you mean.

Your queries are saved in the report solution as part of the dataset - or do you mean that you want to use a report template that contains certain query-based datasets that you often re-use ?

|||

I open VS 2005

Connect to SQL Server 05

Go to Data - new query

write query

run for results

How do I save this query to be used again?

I tried sacing as a project but when I re-open the query is gone.

Also, can I only copy and paste the results or can I eport as .csv etc..?

thanks

|||

You can use storedproc for this. Insted of queries create it as a storedproc and you can call it from the report by choosing thype as storedproc.

As for export, if you are using VS2005 you have a save icon that will export your report to a bunch of formats including excel,csv PDF,etc..

|||

You say you "open VS 2005" but you don't say what type of project you're in. (And before you say anything yes I agree this is totally wacked but this is how it works).

Make sure you're in a data project. If you don't have a data project in your solution add one. You should find it under Projects of Type Other. (don't ask me)

When you choose a New Project of Database type, if I remember correctly, you will be asked to add some database connections. You can always add more later. This is pretty much the "connect to sql server 2005" step, and, in the Solution Explorer, you will see some items under your project called Database References that look like what you see in the Server Explorer.

You will also see some folders which have been created under this Project folder for storage of various types of scripts and queries. YOu don't have to use this organization, but it's the way they set it up by default.

Try right-clicking on the name of your Data project in the Solution Explorer and choose to Add New Item... etc. You will see what you have been looking for on that context menu, I think.

>L<

|||

I do not see what you have listed.

I connected to te server.

I go to data - new query

Create the query but cannot save it for re-use?

I do not see this

- Make sure you're in a data project. If you don't have a data project in your solution add one. You should find it under Projects of Type Other. (don't ask me)

|||

You said you were in Visual Studio, right?

So... let me guess: you're actually in Visual Studio Express?

So you don't see a new project of Data type. OK.

Are you in the Web version or the VB version of Express?

First of all: you can *always* add a file of type Text and then save the SQL out of the SQL pane and add it to a text file in the project. Next time you want to do a New Query you can copy the SQL back into the SQL pane of the query designer.

In the Express version, though, you don't have solutions, you just have projects (of the requisite type: web site or VB or whatever).

In the project, the way you attach a "sense" of data, therefore, is not to associate a project of data type. Instead, you create an item of type "new dataset". In the dataset information, you specify the data connection and you write the query. The dataset is persisted along with information about how it receives its data (sometimes a query, sometimes a stored procedure or whatever).

This is the best I can do to explain. And you've kind of written to the wrong forum... hope it helps anyway.

>L<

No comments:

Post a Comment