dickersonka 104 Veteran Poster

A common question that routinely comes up is how to share data between forms.

I have outlined two common ways to pass data between forms, among many others. I have used a public property on the output form to accept a value and update the display. I also have a method accepting parameters from the input form, to update the display.

On the first form there are three textboxes tbFirstName, tbLastName, and tbSample with a Submit button to redirect to the output form. I have the same layout on the output form to display the passed values.

dickersonka 104

The problem with that would be is that its not a singleton and can exist in multiple classes

[code]
private static readonly GlobalVariables TheSingleGlobalVariableInstance = new GlobalVariables();

    private GlobalVariables()
    {
    }

    public static GlobalVariables  Instance
    {

get
{
return TheSingleGlobalVariableInstance;
}
}
[/code]

The above piece allows only a single instance to exist in the application, which can be called by any class without creating an instance of it

[code]
//you can do this
GlobalVariables.Instance.Result6 = 5;

//you can't do this
GlobalVariables gv = new GlobalVariables();
gv.Result6 = 5;
[/code]

you normally would use this singleton method for a configuration accessor class or a group of data that needs to be shared throught the app without passing a class object around

ddanbe commented: good explanation +4

dickersonka 104

The exe is the compiled solution, all exes have already been compiled as well

if you are in a winforms app, it needs to be compiled before running it, if you are in asp.net you can set the project not to be built until specifically build the project

if your project is getting to be that large, then possibly separate your reference dlls out into a separate solution, and build those when necessary, and have the main app reference the dlls rather than projects

alc6379 commented: very good real-world use case here. +12

dickersonka 104

[code]
select top 3 *
from tableName
order by col3 desc
[/code]

bharatshivram commented: thanx for your reply. +2

dickersonka 104

[code]
System.Diagnostics.Process.Start("calc")
[/code]

chitopolo commented: Thank You very much i was looking for this code like since 2 hours ago..! Thank u again! +0

dickersonka 104

i'm not quite sure what you are trying to do here, but there are 2 things

first you are referencing R3 outside of its scope, second you have a where instead of an and, here is my shot at what i think you are trying to do

[code]
select * from Results RT1
where RT1.RDate = (select max(RT2.RDate) from Results RT2)
and RT1.RTime =
(select max(RT3.RTime) from Results RT3
where RT3.RDate = (select max(RT4.RDate) from Results RT4))
[/code]

Eager_Beever commented: Thanks for pointing out my mistake. +2

dickersonka 104

Ok, just wanted to make sure we aren't chasing a ghost

Rather than just adding the parameters with a name and value, try to add them with a name and type
[code]
SqlParameter param1 = new SqlParameter("@RDate", SqlDbType.DateTime);
param1.Value = dtCurrentDate;
sqlCmdCheckDuplicates.Parameters.Add(param1);
[/code]

and do the same for the other one

dickersonka 104

sorry bout that, was a late night and didn't think twice about it

this will work
[code]
select
(select count(*) from posts p1 where p1.user_id = u.user_id) as post_count,
u.user_id
from users u
left outer join
posts p
on p.user_id = u.user_id
group by u.user_id
[/code]

nav33n commented: works great.. +10

dickersonka 104

right, then the exception is correct

uri is expected to be a registered prefix, and javascript is not, things are working properly!!!

dickersonka 104

are you meaning something like this?

[code=csharp]
foreach (HtmlElement link in webBrowser1.Document.Links)
{
bool isValid = false;
string linkItem = link.GetAttribute("HREF").ToString();

            Uri urlCheck = new Uri(linkItem);
            WebRequest request = WebRequest.Create(urlCheck);
            request.Timeout = 10000;    // 10 seconds

            WebResponse response;
            try
            {
                response = request.GetResponse();
                isValid = true;
                Console.WriteLine("Good");
            }
            catch (Exception)
            {
                Console.WriteLine("Bad"); //url does not exist
            }

           if(isValid)
   {
    listViewLinks.Items.Add(link.GetAttribute("HREF").ToString());
   }
}   

[/code]

dickersonka 104

ok we see your assignment, what have you done so far, what are you having trouble with?

dickersonka 104

here i found an article on the suggestion i gave you earlier

its because order of precedence, also always try to do joins this way, makes much cleaner code

[url]http://damonparker.org/blog/2006/02/23/mysql5-join-syntax-changes/[/url]

filch commented: Once again, a great help! +1

dickersonka 104

[code]
select db_name()
[/code]

omrsafetyo commented: It seems so obvious... +1

dickersonka 104

actually no need to check the uas table at all, just delete, then insert

you are correct, check user table i guess from a login or whatever that is, then no need to check anything against uas table except when displaying the form, on submit delete and insert

also i normally wouldn't suggest this, but i think it is appropriate here, we don't need a uas_id on uas table, it is always being deleted and never referenced, you can keep it, no big deal, its just not of use i see yet, but maybe keep it if you think you will need it later

filch commented: This man is amazing ... really! +1

dickersonka 104

you are correct, String.split is the way to go to treat it the same as the tokenizer

the other way would be to use regex

dickersonka 104

[code]
select DATEDIFF(now(), '2008-12-25)
[/code]

CodeBoy101 commented: Great!!! (^ - ^) +1

dickersonka 104

lol yeh man, it worked fine, will you post the whole class structure then?

ddanbe commented: inspiring +2

dickersonka 104

are you catching the key press event and checking for enter?

[code]
if ((int)e.KeyChar == (int)Keys.Enter)
{
Navigate(toolStripTextBox1.Text);
}
[/code]

dickersonka 104

perfect english :-), lol well at least typing

maybe when the users are on the system tomorrow, run show processlist again, and you can see what may be causing the problem

123468743867143 commented: Simply awesome. Lots of useful information. Very patient with inexperienced person like me. Thank you "Dickersonka". +1

dickersonka 104

depends upon the context, a lot of times you will check to see if bytesRead > -1 or sometimes you check for CRLF (carriage return line feed), other times you will pass how many bytes you will be sending and read until all the bytes have been sent

Antenka commented: Thanks againg for goog and quick help! +1

dickersonka 104

ahhh i see now, i know you may not like the idea, but just name the checkboxes as groups when you are displaying them, on postback only grab the ones for the selected airport (also for each airport)

[code]

[/code]

filch commented: Great patience and good advice. +1

dickersonka 104

are you wanting dynamic variable names?

if so you can't do that in java
you can use an ArrayList or HashMap to store a name and a class

[code]
String userSpecifiedName = "SunServer";
HashMap<String, Simple> map = new HashMap<String, Simple>();

Simple simpleClass = new Simple();
map.put(userSpecifiedName, simpleClass);
[/code]

Ezzaral commented: Yeah, he seems to be wanting a map. Not a very clear question though :) +15

dickersonka 104

sorry, forgot it was java, here's a sample java tcplistener

[url]http://www.koders.com/java/fid857615100E60AA30093DF6D87C3135D7AE75C4F5.aspx[/url]

Antenka commented: Thanks a lot!!!!!!!!!!! +1

dickersonka 104

if you use fxcop or code analysis in visual studio there is a rule CA1806 to 'do not ignore method results'
[url]http://msdn.microsoft.com/en-us/library/ms244717(VS.80).aspx[/url]

ddanbe commented: Thanks for the help +2

dickersonka 104

friend lol, we do seem a bit hostile
i can bet this is the sharekahn app i have saw tons of problems about

just because i am nice, check out this link, the bottom post
[url]http://forums.sun.com/thread.jspa?threadID=776507[/url]

VernonDozier commented: +rep for mind reading ability. I had no idea what the OP was talking about. +8

dickersonka 104

you can pass parameters using

[code]
<applet .....

[/code] in your init [code] String param = getParameter("param"); [/code] just do conversion to int, but you are specify width and height already, but thats how pass them

dickersonka 104

ahhh, math junkie then lol

this might be helpful as well, more of the logic side, than the graphical
[url]http://bytes.com/forum/thread645269.html[/url]

coveredinflies commented: Thanks +1

dickersonka 104

how about

[code]
int myValue = 6000;
Debug.WriteLine(Convert.ToString (myValue, 2));
[/code]

little less lines of code

ddanbe commented: nice! +2

dickersonka 104

Rude, for giving him a link with what it is with code and saying to clarify the question?

Doesn't look like a good way to start off here RC131, when we are trying to help.

ddanbe commented: well said +2

dickersonka 104

here is the sql code to get it

[code]
SELECT
sysobjects.name AS "TABLE_NAME",
syscolumns.name AS "COLUMN_NAME",
systypes.name AS "DATA_TYPE",
syscolumns.LENGTH AS "LENGTH"
FROM
sysobjects
INNER JOIN
syscolumns ON sysobjects.id = syscolumns.id
INNER JOIN
systypes ON syscolumns.xtype = systypes.xtype
WHERE
(sysobjects.xtype = 'U') and
sysobjects.name = 'MyTableName'
ORDER BY sysobjects.name, syscolumns.colid
[/code]

then in your your datacolumn, you will set maxlength to the value returned from the query for length

ddanbe commented: whew cool! +1