Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# Update method from Form to DataClass
Message
De
11/11/2004 12:20:23
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires Web
Versions des environnements
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
00959753
Message ID:
00960521
Vues:
11
Tom,

I'm just curious as to why you're using static methods and variables.

~~Bonnie



>Bonnie;
>
>
>Thank you for your suggestion! It got me to think and resolving this was not an easy issue. I would try changing just one word or concept and have many errors. Then I would have my Form free or errors only to find that there was a problem calling the Data Class. This issue went back and forth.
>
>I did learn a great deal from this exercise about how to use C# and why a specific approach is taken. I would compare my experience resolving this issue with walking through a Mine Field! One step in the wrong place and then the “fun begins”!
>
>Another analogy is a large room filled with mousetraps each having a Ping Pong Ball delicately placed upon it. The object of the exercise is to bounce one Ping Pong Ball across the room without setting off another. If one is set off then WOW! There goes the room! :)
>
>Here is the basic concept that works.
>
>
>On the Form:
>
>
>static string UserID;
>static string FirstName;
>
>
>if (Condition == "Save")
>{
>     UserID = txtUserID.Text;
>     FirstName = txtFirstName.Text;
>     UpdateOneUser(UserID, FirstName);
>
>private void UpdateOneUser(string UserID, string FirstName)
>{
>	ScrapDB.UpdateUser(UserID, FirstName);
>}
>
>
>In the Data Class:
>
>
>public static void UpdateUser(string UserID, string FirstName)  //
>{
>     SqlConnection UpdateUserConnection = GetConnection();
>     string UpdateStatement	= "UPDATE UserInfo SET FirstName = @FirstName WHERE UserID=@UserID";
>		
>			
>     SqlCommand UpdateCommand = new SqlCommand(UpdateStatement, UpdateUserConnection);
>		UpdateCommand.Parameters.Add("@UserID", UserID);
>		UpdateCommand.Parameters.Add("@FirstName", FirstName);
>					
>		UpdateUserConnection.Open();
>
>		UpdateCommand.ExecuteNonQuery();
>	
>		UpdateUserConnection.Close();
>}
>
>
>What was of key importance in resolving two major issues was the use and understanding of the word static. This occurred on both the Form and Data Class. This was an excellent experience.
>
>Tom
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform