troubleshooting Question

Need Help Declaring System.Data.SqlClient Objects in Visual Studio 2008

Avatar of stuengelman
stuengelmanFlag for United States of America asked on
.NET ProgrammingVisual Basic.NETMicrosoft Development
3 Comments1 Solution481 ViewsLast Modified:

I'm writing a simple Windows PC application in VB.NET using VS 2008 and the .NET 3.5 Framework.  My code is intended to simply recycle my MS SQL Error Log.  The code for my startup form appears in the code snippet.

All the commands below "Dim CMD As New SqlCommand" have a design time error.   There is a blue squiggly line under each object (CN and CMD), and when I hover over the object text, the yellow hover box says "Declaration expected."  I am confused as my first two commands (after the "Public Class frmMain" statement) declare both objects.

Any help would be most appreciated.

Thanks, Stu Engelman
Imports System.Data.SqlClient

Public Class frmMain

Dim CN As New SqlConnection
Dim CMD As New SqlCommand
CN.ConnectionString = "Server=(local);Trusted_Connection=True;"
CMD.Connection = CN
CMD.CommandText = "EXEC sp_cycle_errorlog"
CMD = Nothing
CN = Nothing

End Class
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros