Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by Robby
Posted
You cannot change the database of an OleDbConnection object. You need to create another instance of OleDbConnection to access other database.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...