ACHTUNG: das ganze Programm ist dem Beitrag hinzugefügt worden, also braucht Ihr die CODE-Azszüge nicht unbedingt zu lesen
Hallo, 
leider konnte ich an meiner Hochschule keinen Professor finden, der mir mit meinem Problem in C# helfen könnte. Leider arbeite ich selber erst seit wenigen Tagen mit C# und komme daher alleine nicht weiter.
Ich habe ein kleines Programm geschrieben, welches zu einer ACCESS-Datenbank  eine Verbindung aufbaut und dort daraufhin einige Werte ändert.
Leider bekomme ich immer wieder die Meldung:
Die 'ConnectionString'-Eigenschaft darf nicht geändert werden.Der aktuelle Status der Verbindung ist 'Geöffnet'.
Das Problem tritt in der Zeile 47 bei CoDeFSmain.cs, da es in der Klasse DB_Connect.cs in Zeile 44 verursacht wird.
Codeauszüge:
CoDeFSmain.cs
												| 1:2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 40:
 41:
 42:
 43:
 44:
 45:
 46:
 47:
 48:
 49:
 50:
 51:
 52:
 53:
 54:
 55:
 56:
 57:
 58:
 59:
 
 | using System;using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Data.OleDb;
 using System.Data.SqlClient;
 using System.Drawing;
 using System.Text;
 using System.Windows.Forms;
 
 namespace CoDeFS
 {
 public partial class CoDeFSmain : Form
 {
 DB_Connect connect_db = new DB_Connect();
 Start_CoDeFS startcodefs = new Start_CoDeFS();
 public CoDeFSmain()
 {
 InitializeComponent();
 }
 
 
 
 private void Load_OleDBConnection_on_start (object sender, EventArgs e)
 {
 connect_db.con = new OleDbConnection();
 connect_db.Checkdbcon = false;
 }
 
 
 
 
 
 
 private void connect_to_db_Click(object sender, EventArgs e)
 {
 if (connect_db.Checkdbcon == false)
 {
 Db_connection_btn.Text = "disconnect";
 
 OleDbConnection con = connect_db.DBConnect;
 startcodefs.start_codefs(con);
 }
 else
 {
 Db_connection_btn.Text = "connect";
 connect_db.dbdisconnect();
 }
 }
 
 }
 }
 | 
		
	  
DB_Connect.cs
												| 1:2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 40:
 41:
 42:
 43:
 44:
 45:
 46:
 47:
 48:
 49:
 50:
 51:
 52:
 53:
 54:
 55:
 56:
 57:
 58:
 59:
 60:
 61:
 62:
 63:
 64:
 65:
 66:
 67:
 68:
 69:
 70:
 71:
 72:
 73:
 74:
 75:
 76:
 77:
 78:
 79:
 80:
 81:
 
 | using System;                                                                       using System.Collections.Generic;
 using System.Data.OleDb;
 using System.Data.SqlClient;
 using System.Text;
 using System.Windows.Forms;
 
 namespace CoDeFS
 {
 class DB_Connect
 {
 public OleDbConnection con = new OleDbConnection();
 private string pfad_codefsinterface = "Data Source=C:\\Projects\\Cogfacinterface.mdb";
 private bool checkcon;
 
 
 
 
 public OleDbConnection DBConnect
 {
 get
 {
 con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;";
 con.ConnectionString += pfad_codefsinterface;
 try
 {
 con.Open();
 checkcon = true;
 return con;
 }
 catch (OleDbException er)
 {
 MessageBox.Show(er.Message);
 }
 return null;
 }
 set
 {
 con = value;
 }
 }
 
 
 
 public void dbdisconnect()
 {
 try
 {
 con.Close();
 }
 catch (OleDbException er)
 {
 MessageBox.Show(er.Message);                                                        }
 
 checkcon = false;
 }
 
 
 
 
 
 public bool Checkdbcon
 {
 get
 {
 return this.checkcon;
 }
 set
 {
 this.checkcon = value;
 }
 }
 }
 }
 | 
		
	  
Start_CoDeFS.cs
		                     
             C#-Quelltext
                        C#-Quelltext                    
           	 										| 1:2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 
 | using System;using System.Collections.Generic;
 using System.Text;
 using System.Windows.Forms;
 using System.Data.OleDb;
 
 
 namespace CoDeFS
 {
 class Start_CoDeFS
 {
 DB_Connect checkconnection = new DB_Connect();
 Application_State set_state = new Application_State();
 private string applicationstate;
 
 
 
 
 
 
 public void start_codefs(OleDbConnection con)
 {
 applicationstate = "start";
 set_state.set_application_state(applicationstate,con);
 }
 }
 }
 | 
		
	  
Application_State.cs
												| 1:2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 
 | using System;using System.Collections.Generic;
 using System.Data.OleDb;
 using System.Data.SqlClient;
 
 using System.Text;
 
 namespace CoDeFS
 {
 class Application_State
 {
 DB_Connect connect = new DB_Connect();
 private int iRowsAffeced;
 private string set_state_ready = "UPDATE [cosimirinterface] SET spalte2 = 'ready' WHERE [spalte1] = 'CoDeFS'";
 private string set_state_not_ready = "UPDATE [Application_State] SET application_state = 'not ready' WHERE [application_name] = 'CoDeFS'";
 
 
 
 
 
 
 public void set_application_state(string state, OleDbConnection con)
 {
 if (state == "start")
 {
 state = set_state_ready;
 }
 else
 {
 state = set_state_not_ready;
 }
 
 OleDbCommand stateUpdCmd = new OleDbCommand(set_state_ready, con);
 iRowsAffeced = stateUpdCmd.ExecuteNonQuery();
 }
 }
 }
 | 
		
	  
Moderiert von  Christian S.: Quote- durch C#-Tags ersetztModeriert von
Christian S.: Quote- durch C#-Tags ersetztModeriert von  Christian S.: Topic aus C# - Die Sprache verschoben am Mo 19.11.2007 um 13:58
Christian S.: Topic aus C# - Die Sprache verschoben am Mo 19.11.2007 um 13:58