Pull data from SQL database and display it on Umbraco site. We are on version 4.5
I have a requirement where I have to pull data from SQL database and display it on Umbraco site in a small section. This section has to be available to everyone who goes to the web site. There is no security attached. I was looking at the below link but it was talking about a user control and providing Membership settings. I don't think I need it. Please Advise.
Please ignore see below link comment on the above post. We are trying to insert the middle section on the above image on our website. It currently looks like this.
You should be able to create .Net usercontrol that gets the data you want and renders the display. Then create a macro for the new control and place it on the homepage template
I was able to create .Net user control and display sample static data. However when I am trying to get data for certain fields like 0.95% above from the database, the page is giving me an error. Here is my code.
Pull data from SQL database and display it on Umbraco site. We are on version 4.5
I have a requirement where I have to pull data from SQL database and display it on Umbraco site in a small section. This section has to be available to everyone who goes to the web site. There is no security attached. I was looking at the below link but it was talking about a user control and providing Membership settings. I don't think I need it. Please Advise.
Please ignore see below link comment on the above post. We are trying to insert the middle section on the above image on our website. It currently looks like this.
www.archetypemortgage.com
You should be able to create .Net usercontrol that gets the data you want and renders the display. Then create a macro for the new control and place it on the homepage template
Hi Sean,
I was able to create .Net user control and display sample static data. However when I am trying to get data for certain fields like 0.95% above from the database, the page is giving me an error. Here is my code.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Data.SqlClient;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
namespace
HelloWorld
{
publicpartialclassHelloWorld : System.Web.UI.
UserControl
{
protectedvoid Page_Load(object sender, EventArgs
e)
{
if
(!IsPostBack)
{
string FiveYSwap = null;
// your page title here
string myConnectionString = "server=MDCSQL12;database=AMC;Integrated Security=yes;";
//you connectionstring goes here
SqlCommand cmd = newSqlCommand("SELECT MAX([ InterestRateSwap Ask]) AS Expr1 FROM AMCSwap$ WHERE ([ InterestRateSwap Symbol] = 'USDIRSAN05Yv_03M')" + FiveYSwap.Replace("'", "''") + "'", newSqlConnection
(myConnectionString));
cmd.Connection.Open();
labelPrice.Text = cmd.ExecuteScalar().ToString();
// assign to your label
cmd.Connection.Close();
}
}
}
}
Please Advise.
Actually I figured out the problem with my code.. Its working now. Thanks
is working on a reply...