Solved

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

Posted on 2006-07-04
6
290 Views
Last Modified: 2010-04-23
hi,
my project works in 2003
1.
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

2.
DialogResult:
dim frmA as new frmMyForm
frmA.showDialog()
if frmA.dialogresult= dialogresult.ok then
 messgebox.show("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.


3.
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?

4.
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.


thanks!!!
0
Comment
Question by:jxharding
  • 3
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
jjardine earned 300 total points
ID: 17036628
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 = _
            connections(name).ConnectionString
            Dim provider As String = _
            connections(name).ProviderName
           
            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.
0
 
LVL 12

Assisted Solution

by:gbzhhu
gbzhhu earned 200 total points
ID: 17036848
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
0
 

Author Comment

by:jxharding
ID: 17036948
thank you both very much
could i just ask : will my connectionstring totally change from this:

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

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

thanks!
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:jxharding
ID: 17037037
could i just get some more info on q2 pls
DialogResult:
dim frmA as new frmMyForm
frmA.showDialog()
if frmA.dialogresult= dialogresult.ok then
 messgebox.show("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

thanks!
0
 

Author Comment

by:jxharding
ID: 17037066
ok,sorted out the last post, thank you very much.
could someone pls post a sample of a connectionstring xml file
thanks!
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 17037101
Should be able to get all you need about app.config here

http://geekswithblogs.net/akraus1/articles/64871.aspx
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question