Showing posts with label objects. Show all posts
Showing posts with label objects. Show all posts

Wednesday, March 7, 2012

Closing ADO objects

I know it's "best practice" to dispose ado.net objects, but does it make a big difference if just the connection is closed?

In other words, is the code below good enough or should the DataAdapter & Command be explicitly closed?

using (SqlConneciton cn = new SqlConnection(connstr))

{

SqlDataAdapter da = new SqlDataAdapter(sql,cn);

DataSet ds = new DataSet();

da.Fill(ds);

SqlCommand cmd = new SqlCommand(someOtherSql,cn);

cmd.ExecuteNonQuery();

}

Most will be handled by the garbage collector and its all around no big deal. As far as I know, th eone you need to worrie about a lot, is the SqlDataReader: not closing these make for crazy performance overhead.|||

Hi John,

Actually, you don't need to call dispose. The Dispose method is used to release unmanaged resources. Since Close has already been called, the connection will be put back to pool automatically.

IMO, just call Close. That's enough. If you're using "using" statement, it's better. It will call dispose automatically.

HTH. If this does not answer your question, please feel free to mark the post as Not Answered and reply. Thank you!

Friday, February 24, 2012

Client Tools for SQL Express

I am looking for information on Client tools for SQL Express. I am mainly looking for a way to script out the objects and then Add them back into a new file. I wish to do this so that I can ship the SQL Scripts for an application so that the user can load them up once distributed, and also to allow me to create the objects and load them at design time. I used to be able to have a common set of tables that I would use inside applications, and when working on a project load them if they were needed.
One of the other reasons is the problem with the Beta2 and RC engines and the changes that have been made. I know that the two versions do not work well together and I want to be able to script out the objects and put them into either the RC or in turn the RTM Version.
I know that there are the management tools that ship with the full sql product (Not Express), but I fell that there should not be a need to install these as there should be some command line tools that can do the job. I have seen the command line tool on the MSDN Download site, but could not see how to script out the objects.

Maybe I could use the SQLCMD tool but I can not work out how to connect to the mdf file as I do not have a server running as it is the express edition. (Even though it ships with the express edition).I'm not sure I understand the following statement: "Maybe I could use the SQLCMD tool but I can not work out how to connect to the mdf file as I do not have a server running as it is the express edition."

In order to use SQL Server Express the SQL Server service must be running. Once it's running you can connect using SQLCMD (sqlcmd -S .\SQLEXPRESS -E).

Best of luck,
Dan|||Thanks for that, I have been able to connect to the SQL Express engine using the SQLEUtil (I think thats it) that you can download from the Microsoft downloads site, but still trying to script out the database objects.

What I have started looking at is the SQL-SMO System (http://www.ircomm.net/blogs/mykre/archive/2005/10/18/615.aspx), with this I hope to develop a system that I can use to script out the Database objects (Table structure and all). This way I will be able to use this system to store my SQL Scripts in a source code management system, or publish the scripts that I develop with my applications.

One of the main reasons at present is that I have been running Beta 2 of the framework at home, and am now running the RC version at work. When I tried to move an application from home to work the MDF Files where not compatible and I needed to recreate them. As the Release draws near I am worried as I have Beta 2 database files that I am working with and when new version is released how am I going to recreate the files.

I also can for see a problem here at work which I have posted in the following post, http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=111170.

Sunday, February 12, 2012

Click-through on graph bars and objects?

Can you do click-throughs on Reporting Services 2005 Graphs whereas if I have created a dashboard somehow with 4 reporting services charts on our Intranet, that a user can click on a bar in the graph and it would drill down into an automated click-through report for that user?it is possible|||Does the earlier version of Report Services (2000, not 2005) support click-through on graph bars as well?|||Peter, I don't think so...|||By the way, I'm loving SSRS 2005, it rocks compared to Crystal! much easier and no more Crystal syntax! only VB.NET! can't get much better than that.|||

Yes, RS 2000 has the same drill through capabilities in charts.

-- Robert

|||

Can you go over how this is accomplished?
Thanks!!

Click-through on graph bars and objects?

Can you do click-throughs on Reporting Services 2005 Graphs whereas if I have created a dashboard somehow with 4 reporting services charts on our Intranet, that a user can click on a bar in the graph and it would drill down into an automated click-through report for that user?it is possible|||Does the earlier version of Report Services (2000, not 2005) support click-through on graph bars as well?|||Peter, I don't think so...|||By the way, I'm loving SSRS 2005, it rocks compared to Crystal! much easier and no more Crystal syntax! only VB.NET! can't get much better than that.|||

Yes, RS 2000 has the same drill through capabilities in charts.

-- Robert

|||

Can you go over how this is accomplished?
Thanks!!

Click-through on graph bars and objects?

Can you do click-throughs on Reporting Services 2005 Graphs whereas if I have created a dashboard somehow with 4 reporting services charts on our Intranet, that a user can click on a bar in the graph and it would drill down into an automated click-through report for that user?it is possible|||Does the earlier version of Report Services (2000, not 2005) support click-through on graph bars as well?|||Peter, I don't think so...|||By the way, I'm loving SSRS 2005, it rocks compared to Crystal! much easier and no more Crystal syntax! only VB.NET! can't get much better than that.|||

Yes, RS 2000 has the same drill through capabilities in charts.

-- Robert

|||

Can you go over how this is accomplished?
Thanks!!