from 2003-2005: How do i get a form's dialogresult now and how to use cursor.current + declare a connectionstring

my project works in 2003
cursor.current does not work at all now.
it gives me the error:
Access of Shared Member,constant member,enum member or nested type through an instance; qualifying expressin will not be validated

dim frmA as new frmMyForm
if frmA.dialogresult= dialogresult.ok then"OK")
end if

this gives me the error:
Access of shared member,constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.

i have a connection string which i use AND DECLARE on every single page.
Dim mySqlConnection As SqlConnection
mySqlConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectionString"))

a) is there a way i can only declare this once in the project and use it throughout?
b) how will this look in 2005?

i get the error:
'Public Shared ReadOnly Property AppSettings() as System.collection.specialized.namevalueCollection' is obsolete:
This Methid is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.Appsettings.

c) can i somehow use this new method in my 2003 so that hte upgrade part will be quicker?

i just wanna confirm : in a non MDI child environment,
would it ever make sense to use
Me.globalform = Me  (in the load section of a form)
i want to delete it out of the whole project.

Who is Participating?
jjardineConnect With a Mentor Commented:
To Answer your 1st Question:
change Cursor.current to Windows.Forms.Cursor.Current

To Answer your 2nd Question:
DialogResult.ok  is now  Windows.Forms.DialogResult.OK    If you try this it should fix this for you.

Question 3:
The reason you are getting the error about appSettings is that they have added a new way to get to the configuration settings.   you should now add a reference to System.Configuration  and use ConfigurationManager.AppSettings(<nameofSetting).ToString().   With that being said they have added a new item to the app.config for connection strings which can also be captured using the ConfigurationManager class. an example of how to pull these from the new settings is:

Dim connections as ConnectionStringSettingsCollection = ConfigurationManager.ConnectionStrings
 Dim conEnum As IEnumerator = connections.GetEnumerator()
        Dim i As Integer = 0
        While conEnum.MoveNext()
            Dim name As String = connections(i).Name
            Dim connectionString As String = _
            Dim provider As String = _
            Console.WriteLine("Name:               {0}", name)
            Console.WriteLine("Connection string:  {0}", connectionString)
            Console.WriteLine("Provider:           {0}", provider)
        End While

As far as an easier place to store the connection string in one location instead of accessing the AppSettings class all of the time, you could declare a variable in a module that is accessible to the entire project and set it on load.  I am not a fan of modules but it could be done that way.  

Question 4:
   I have never set Me.globalform = me before in a project and all of mine work fine.   I don't think this is needed.
gbzhhuConnect With a Mentor Commented:
jjardine answered it all but I could add something to question 3

You can create a class (rather than a module).  Add a shared/static property that will hold the connection string.  Set it at the beginning of the app and fetch it from there everytime you need it
jxhardingAuthor Commented:
thank you both very much
could i just ask : will my connectionstring totally change from this:

<?xml version="1.0" encoding="utf-8"?>
<add key="ConnectionString" value="Data Source=MyServer; database=ABC; UiD=sa;Password=123;" />

can i change it now in 2003 to be 2005 compatible?

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

jxhardingAuthor Commented:
could i just get some more info on q2 pls
dim frmA as new frmMyForm
if frmA.dialogresult= dialogresult.ok then"OK")
end if

i have a form and when the user presses the ok button, i set the dialogresult as ok.
i just dont know how to handle this situation in 2005.
i understand the windows.forms.dialogresult, but i dont know how to set it as
if frmA.dialogresult = windows.forms.dialogresult.ok <--- dont work

jxhardingAuthor Commented:
ok,sorted out the last post, thank you very much.
could someone pls post a sample of a connectionstring xml file
Should be able to get all you need about app.config here
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.