Duckjibe Posted July 30, 2003 Posted July 30, 2003 (edited) private void Form1_Load(object sender, System.EventArgs e) { string Serverpath; try { // Create an instance of StreamReader to read from a file. // The using statement also closes the StreamReader. using(StreamReader sr = new StreamReader("Serverpath.txt")) { Serverpath = sr.ReadLine(); } setpath(Serverpath); } catch(Exception ex) { MessageBox.Show("File Could not be Read " + ex); } } private void setpath(string str) { Data_Connection.DataSource = str; } I just want to change the datasource cause the user want to place the database a location(server) i dont know yet! So im writing userinput to a file and reading it at formload. My problem is that when i compile it says Property or indexer 'System.Data.OleDb.OleDbConnection.DataSource' cannot be assigned to -- it is read only How do i avoid this??? How can i change the datasource location at runtime??? Please help! Edited August 1, 2003 by Robby Quote
Moderators Robby Posted August 1, 2003 Moderators Posted August 1, 2003 what is 'Data_Connection' ? Quote Visit...Bassic Software
jssk Posted August 2, 2003 Posted August 2, 2003 You cannot change the database of an OleDbConnection object. You need to create another instance of OleDbConnection to access other database. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.