I'm using umbraco v6 (newbie) and VS2012 express. Currently in a localhost dev setup
I have created a new database and added the connection string (<add name="umbracoGearBox" connectionString="Data Source=|DataDirectory|\gearbox.sdf" providerName="System.Data.SqlServerCe.4.0"/>) to the web.config file. I can access the new database using razor within umbraco. However Using VS2012 c# .net control I can't seem to connect to the database to then query the dataset. I have googled and tried various connection settings but can't seem to get it working?? Surley it can't be that hard? Please help..
Can you paste your usercontrol code please. Also which exact version of v6 are you using? Also are you trying to access custom tables in the db or umbraco tables?
Thankyou for the reply... I think I have at least got something working..
I'm using Umbraco v6.0.7. I have created my own custom database called gearbox.sdf, I want to query the table called gearbox and filter out results depending on selections from 3 dynamic dropdown lists. The code below is how far I have got up to now. As long as I'm on the right track I'm sure I can figure out the remaining code..
In the latest version of umbraco you can use the abstracted data layer that uses peta poco so that does all the work for you. However in your version you can also use the old data layer
How to connect to a new database?
Hi,
I'm using umbraco v6 (newbie) and VS2012 express. Currently in a localhost dev setup
I have created a new database and added the connection string (<add name="umbracoGearBox" connectionString="Data Source=|DataDirectory|\gearbox.sdf" providerName="System.Data.SqlServerCe.4.0"/>) to the web.config file. I can access the new database using razor within umbraco. However Using VS2012 c# .net control I can't seem to connect to the database to then query the dataset. I have googled and tried various connection settings but can't seem to get it working?? Surley it can't be that hard? Please help..
many thanks
ian
Ian,
Can you paste your usercontrol code please. Also which exact version of v6 are you using? Also are you trying to access custom tables in the db or umbraco tables?
regards
Ismail
Hi Ismail,
Thankyou for the reply... I think I have at least got something working..
I'm using Umbraco v6.0.7. I have created my own custom database called gearbox.sdf, I want to query the table called gearbox and filter out results depending on selections from 3 dynamic dropdown lists. The code below is how far I have got up to now. As long as I'm on the right track I'm sure I can figure out the remaining code..
protected void list1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlCeConnection con = new SqlCeConnection(System.Configuration.ConfigurationManager.ConnectionStrings["umbracoGearBox"].ConnectionString);
con.Open();
SqlCeCommand command = new SqlCeCommand("SELECT * FROM gearbox", con); //would query a specific field string here depending on ddlist selection
SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(command);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
tester.Text = ds.Tables[0].Rows.Count.ToString(); //display record count found to test
con.Close();
}
ian
Ian,
In the latest version of umbraco you can use the abstracted data layer that uses peta poco so that does all the work for you. However in your version you can also use the old data layer
proabably want executereader. It is db agnostic so works with sql server and sql ce as far as i am aware.
Regards
Ismail
thanks Ismail I'll look into it.
ian
is working on a reply...