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
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 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