ASP.NET Web Methoden alphabetisch ordnen beim Suchen nach WebServices

ASP.NET Order Web Methods alphabetically when you browse to a web service open up: C:\\Microsoft.NET\Framework\v1.1.4322\CONFIG\DefaultWsdlHelpGenerator.aspx (this is the file which generates the default documentation depending on your version of the framework) in line 1285 change Hashtable methodsTable = new Hashtable(); to SortedList methodsTable = new SortedList(); Order Web Methods alphabetically when you browse to a web service

Connection Strings --> .NET Data Provider

Probleme mit den ConnectionStrings für eine Datenbankverbindung können mit hoher Sicherheit hier gelöst werden: .NET Data Provider Connection Strings

Für Visual Studio Einsteiger Empfehlung: um ShortCuts bzw. ShortKeys zu lernen

In Visual Studio (VS.NET) auf: Tools -> Customize gehen und dort: Options "Show shortcut keys in Screen Tips" jetzt werden in den ToolTips die ShortKeys angezeigt und man lernt sie langsam.....aber sicher....

DataGrid Identity Increment Conflicts with MS SQL Server

Problem: Datenbank mit Tabelle wo Primary Key AutoIncrement ist. Also auf Client Seite im DataSet AutoIncrement und auf DB-Server Seite AutoIncrement. Diese 2 Seiten zu synchronisieren! Lösung Updated Link! DataGrid Identity Increment Conflicts with MS SQL Server Lösung weil SQL Server Insert Statement: After the INSERT statement occurs a proceeding SELECT is used to retrieve a 'refreshed' version of the record from the MS SQL Server database As you can see by the image above, after hitting the Save button, the SqlDataAdapter sends the INSERT statement to MS SQL Server and then retrieves an updated version of the record from the database via a SELECT statement. The correct identity value is retrieved from the database (26), but as you can see, it doesn't appear in the DataGrid - the original value is still there! Even though the correctly retrieved identity value is set to the Current version of the DataRow, it is not so in the DataGrid. The Current version contains the correct value. The Original version does not. The DataGrid cell objects bind to the Original version of the DataRow object. So, the key is to update the DataRow's TestID column, in this example, to the correct value so we can see it in the DataGrid control. To do that we need to create an SqlDataAdapter RowUpdated event handler and update the Original version value to that of the Current value like this:

private void sqlDataAdapter1_RowUpdated(object sender, 
 System.Data.SqlClient.SqlRowUpdatedEventArgs e)
{
 if (e.Row.HasVersion(DataRowVersion.Original) && 
  e.Row.HasVersion(DataRowVersion.Current) &&
  e.Row.RowState != DataRowState.Deleted) 
 {
  dsDataSetIdentityProblemTest1.tblTest.FindByTestID(
   int.Parse(e.Row[0, DataRowVersion.Original].ToString())).TestID = 
   int.Parse(e.Row[0, DataRowVersion.Current].ToString());
 }
}

ADO.NET ConnectionString verschlüsseln damit Passwort nicht mehr im Klartext (.cs + .exe Datei) sichtbar

Encrypted ConnectionString Mit dieser Solution ist es möglich den ConnectionString der normalerweise im Klartext in der .cs Datei bzw. .exe Datei steht zu verschlüsseln und in der Applikation wieder zu entschlüsseln. 1. Zuerst wird der ConnectionString in einer "Applikation".config Datei verschlüsselt abgespeichert mit dem EncryptedConnectionStringBuilderProject Projekt. 2. Danach wird in der Applikation dieser String wieder ausgelesen über: z.B.: SqlServerConnectionString ExampleConnectionString = new SqlServerConnectionString("SqlServer"); SqlConnection connection = new SqlConnection(ExampleConnectionString.GetValue()); et voila : ConnectionString mit Password ist nirgends mehr ersichtlich. PROBLEM: Ich behaupte, wenn jemand meine .config hat, kann er sich auch den ConnectionString holen, genau gleich wie ich es im Code mache. Dürfte für diesen kein Problem sein.

Events richtig auslösen Thread Safe!!

If an event in C# has no delegates registered with it, attempting to raise the event will cause a NullReferenceException. As a result, given an event declared as public event EventHandler MyEvent; you'll often see it raised with code such as: if (MyEvent != null) MyEvent(this, EventArgs.Empty); This works fine in a single-threaded environment, but consider the scenario in which multiple threads are accessing MyEvent simultaneously. In such a case, one thread could check whether MyEvent is null and determine that it isn't. Just after doing so, another thread could remove the last registered delegate from MyEvent. When the first thread attempts to raise MyEvent, an exception will be thrown. A better way to avoid this scenario is shown in the following code snippet: void MyEventInvoke(object sender, EventArgs args) {     EventHandler ev = MyEvent;     if (ev != null) ev(sender, args); } Whenever a delegate is added to or removed from an event using the default implementations of the add and remove accessors, the Delegate.Combine and Delegate.Remove static methods are used. These methods return a new instance of a delegate, rather than modifying the ones passed to it. In addition, assignments of object references in .NET are thread-safe, and the default implementations of the add and remove event accessors are synchronized. As such, the previous code succeeds by first copying the multicast delegate from the event to a temporary variable. Any changes to MyEvent after this point will not affect the copy you've made and stored. You can now safely test whether any delegates were registered and subsequently invoke them.

Client-Server; Master-Detail Tabelle ..... Fill und Update DeadLock

Ich habe folgendes Problem:
 Ich besitze einen Windows-Forms-Client mit meinem DataSet, das ich beim Start der Anwendung mit Daten vom Server fülle.

--------------------
oracleDataAdapterMaster.Fill(datasetTest);
oracleDataAdapterClient.Fill(datasetTest);
--------------------

 Beim Beenden der Applikation speichere ich die gemachten Änderungen wieder zurück in die Datenbank und zwar per:
(Reihenfolge wichtig)
--------------------
oracleDataAdapterMaster.Update(datasetTest);
oracleDataAdapterDetail.Update(datasetTest);
--------------------

 Nur funktioniert das natürlich nicht wenn ein MasterDatensatz mit samt seinen Details gelöscht wurde.
Denn zuerst will der DataAdapter die MasterTabelle schreiben (delete, update,insert), aber es existieren noch DetailDatensätze in der DetailTabelle.

Denn in der DB wurde eine Beziehung mit referent. Integrität definiert und wir wollen kein

ON DELETE CASCADE

  Lösung: (von Stephan Kerbei)

Die Lösung könnte sein, das DataSet zu splitten. Z.B.so:
 --------------------

// macht ein neues DS, in dem nur die "neuen" Rows aus dem alten DS stehen.

DataSet Dummy = grossesDataSet.GetChanges(DataRowState.Added);
 myAdapter.Update(Dummy);
 // macht ein neues DS, in dem nur die gelöschten Rows aus dem alten DS stehen.
Dummy = grossesDataSet.GetChanges(DataRowState.Deleted); 
myAdapter.Update(Dummy);

--------------------
 Persönliche Meinung (Stephan Kerbei):
  Der DataAdapter ist prima, wenn man "mal eben schnell" was machen will. Für größere, professionelle Anwendungen taugt er nicht. Zum einen ist er sehr langsam, zum anderen gibt es Aufgabenstellungen, die er nicht in den Griff kriegt. Oft ist das Arbeiten mit einem Command-Objekt die bessere Lösung.

Wie übergibt man einen Datum-Parameter an ein Oracle Select Command? UNABHÄNGIG von den Systemeinstellungen

//Select Statement
string dauerSelectCommand = " SELECT SUM(*) FROM myTable WHERE Datum > :PVon" ;

 // neuen OracleCommand instantieren
System.Data.OracleClient.OracleCommand dauerSelect = new System.Data.OracleClient.OracleCommand(dauerSelectCommand, oracleConnection1);

 // WICHTIG!! CultureInfo auf true setzen damit Systemeinstellungen verwendet werde
 // the Boolean specifies whether to use the user-selected culture settings from the system.
System.Globalization.CultureInfo myCIintl = new System.Globalization.CultureInfo( "", true );

 // Datum erzeugen DateTime myDatum = new DateTime( );
myDatum = Convert.ToDateTime(dateTimePickerNullableVon.Value,myCIintl);

 // Parameter dem Command übergeben und dieses dann ausführen
z.B. mit
ExecuteScalar dauerSelect.Parameters.Add( new System.Data.OracleClient.OracleParameter("PVon", myDatum ));

How to add Visual Styles (the Windows XP look and feel) to your C# Application

MyApplication.exe.manifest ins bin/debug und bin/release Verzeichnis legen <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity    version="1.0.0.0"    processorArchitecture="X86"    name="MyVisualStyleApp"    type="win32" /> <description>Beschreibung meiner Applikations Programm Jojo Peter was here <dependency>   <dependentAssembly>    <assemblyIdentity     type="win32"     name="Microsoft.Windows.Common-Controls"     version="6.0.0.0"     processorArchitecture="X86"     publicKeyToken="6595b64144ccf1df"     language="*"    />   </dependentAssembly> </dependency> </assembly> Von Hier

How to suppress paint during resize

Von:Shawn Burke [MSFT] (sburke_online@no.spamming.microsoft.com) Betrifft:Re: How to suppress paint during resize View: Complete Thread (10 Beiträge) Rather than using a timer you should turn off resize-redraw, and use the Idle event to invalidate and cause the paint after the resize: public class MyControl : UserControl { private idleSet = false; protected void override OnResize(EventArgs e) { if (!idleSet) { idleSet = true; Application.Idle += new EventHandler(this.OnIdle); } base.OnResize(e); } private void OnIdle(object sender, EventArgs e) { idleSet = false; Application.Idle -= new EventHandler(this.OnIdle); Invalidate(); } } Suppress Paint on Resize

Application.DoEvents();


Application.DoEvents(); Wieso wird der Focus nicht sofort auf meine TextBox gesetzt? Da ich gerade einen andere EventHandler ausführe, warten die anderen noch... Mit Application.DoEvents() werden die anderen Events abgehandelt. // Focus auf 1. TextBox setzen textBox24.Focus(); Application.DoEvents(); ... aus MSDN: Each time the form handles an event, it processes all the code associated with that event. All other events wait in the queue.

Sql Debugging Stored Procedures

Um im SQL Server Stored Procedures zu debuggen muss man: - You need to grant your Login bzw. Rolle to sp_sdidebug (versteckt in master.Extended Stored Procedurs). - exec sp_sdidebug ausführen

AutoScroll Panel mit eigenen Controls füllen


Wenn man Controls einem Panel hinzufügt und vorher .SuspendLayout() macht muss man danach Invalidate und PerformLayout machen damit di Scrollbars angezeigt werden, sonst checkt es dass .net Framework nicht. Autoscroll im Panel muss auf true sein als Voraussetzung. this.SuspendLayout(); panelDataGrid.SuspendLayout(); ... add Controls zu Panel.. .... this.ResumeLayout(true); panelDataGrid.ResumeLayout(true); panelDataGrid.Invalidate(); panelDataGrid.PerformLayout();

Latest Posts

Popular Posts