C#:
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!
Last edited by a moderator: