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
285 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:jxharding
Comment Utility
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
Comment Utility
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
Comment Utility
Should be able to get all you need about app.config here

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now