Thursday, November 29, 2012
Wednesday, August 22, 2012
The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine. in Server
There are times when the coexistence of 64 and 32 bit code on the same machine can cause all sorts of seemingly strange issues.
One of them just occurred to me while trying to run the ASPx demos from Developer Express, my main provider of .Net components (the best supplier I’ve ever been able to find).
I was getting the following error:
The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine:

It may look otherwise, but this error is generally due to either of two thing:
For the second one, the fix is also easy enough:

Under there you can call the DefaultAppPool’s advanced settings to change

You may have to restart the service for it to take effect but it should work.
Source: http://blog.nkadesign.com
One of them just occurred to me while trying to run the ASPx demos from Developer Express, my main provider of .Net components (the best supplier I’ve ever been able to find).
I was getting the following error:
The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine:
- you don’t have Office 2007/2010 Jet drivers installed
- or you are running a 32 bit application in a default x64 environment.
For the second one, the fix is also easy enough:
- For Windows 2008: Navigate to Server Manager > Roles > Web Server (IIS) > Internet Information Services (IIS) Manager, then look under your machine name > Application Pool.
- For Windows 7: Navigate to Programs > Administrative Tools > Internet Information Services (IIS) Manager, then look under your machine name > Application Pool.
Enable 32-Bits Applications to True:Source: http://blog.nkadesign.com
Friday, July 27, 2012
How to show aspxpopup control on button click instead of enter key press
Steps:
====
1. I have two textboxes and one button and one aspxpopupcontrol in a aspxwebpage
2. I attached Keypress event for two textboxes and i have attached button OnClientClick event from C# code behind to show aspxpopupcontrol.
3. Here problem is when ever i enter some data in any one of the text and press enter it is executing textbox keypress event as well as it showing aspxpopupcontrol. it very annoying to the user.
4. I resolved this issue by using the following devexpress client side method in textbox keypress event.
ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);
Example:
========
<dx:ASPxTextBox runat="server" ID="txtSearch" ClientInstanceName="txtSearch" NullText="Search by Text" Style="border-radius: 4px 4px 4px 4px;">
<ClientSideEvents KeyPress="function(s,e){
var keypressed=ASPxClientUtils.GetKeyCode(e.htmlEvent);
if(keypressed ==13)
{
//Your client side functionality goes here
ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);
}}" />
</dx:ASPxTextBox>
<dx:ASPxTextBox runat="server" ID="txtTagSearch" ClientInstanceName="txtTagSearch" NullText="Search by Tag" Style="border-radius: 4px 4px 4px 4px;">
<ClientSideEvents KeyPress="function(s,e){
var keypressed=ASPxClientUtils.GetKeyCode(e.htmlEvent);
if(keypressed ==13)
{
//Your client side functionality goes here
ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);
}}" />
</dx:ASPxTextBox>
</dx:PopupControlContentControl>
</ContentCollection>
</dx:ASPxPopupControl>
Reference to resolve above issue
Please let me know if you have any doubts on this.
====
1. I have two textboxes and one button and one aspxpopupcontrol in a aspxwebpage
2. I attached Keypress event for two textboxes and i have attached button OnClientClick event from C# code behind to show aspxpopupcontrol.
3. Here problem is when ever i enter some data in any one of the text and press enter it is executing textbox keypress event as well as it showing aspxpopupcontrol. it very annoying to the user.
4. I resolved this issue by using the following devexpress client side method in textbox keypress event.
ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);
Example:
========
<dx:ASPxTextBox runat="server" ID="txtSearch" ClientInstanceName="txtSearch" NullText="Search by Text" Style="border-radius: 4px 4px 4px 4px;">
<ClientSideEvents KeyPress="function(s,e){
var keypressed=ASPxClientUtils.GetKeyCode(e.htmlEvent);
if(keypressed ==13)
{
//Your client side functionality goes here
ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);
}}" />
</dx:ASPxTextBox>
<dx:ASPxTextBox runat="server" ID="txtTagSearch" ClientInstanceName="txtTagSearch" NullText="Search by Tag" Style="border-radius: 4px 4px 4px 4px;">
<ClientSideEvents KeyPress="function(s,e){
var keypressed=ASPxClientUtils.GetKeyCode(e.htmlEvent);
if(keypressed ==13)
{
//Your client side functionality goes here
ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);
}}" />
</dx:ASPxTextBox>
<asp:ImageButton ID="btnShowCustomViewBuilder" CausesValidation="true" runat="server" ImageUrl="~/Styles/Images/FilterIcon.png"
OnClientClick=" popup.Show(); return false" />
OnClientClick=" popup.Show(); return false" />
<dx:ASPxPopupControl ID="AspxPopupControl1" runat="server" Modal="True" AutoUpdatePosition="true" HeaderStyle-Font-Bold="true"
PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" AllowDragging="true" AccessibilityCompliant="false"
ShowLoadingPanel="false" HeaderText="Example Popup" ClientInstanceName="popup" PopupAction="LeftMouseClick"
Width="520px">
<ContentCollection>
<dx:PopupControlContentControl ID="PopupControlContentControl3" runat="server" SupportsDisabledAttribute="True">
PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" AllowDragging="true" AccessibilityCompliant="false"
ShowLoadingPanel="false" HeaderText="Example Popup" ClientInstanceName="popup" PopupAction="LeftMouseClick"
Width="520px">
<ContentCollection>
<dx:PopupControlContentControl ID="PopupControlContentControl3" runat="server" SupportsDisabledAttribute="True">
<table>
<tr>
<td> //Your content goes here </td>
</tr>
</table>
</ContentCollection>
</dx:ASPxPopupControl>
Reference to resolve above issue
Please let me know if you have any doubts on this.
Monday, July 23, 2012
How to Display row value as Column Name in SQL Server
Static Query:
=========
SELECT branch1,branch2,Name,Id FROM (SELECT top 5 tb.* from Users as tb
) AS PivotData
PIVOT (COUNT(Location) FOR Branch IN (branch1,branch2) ) AS PivotTabllumns
Dynamic Query:
============
'SELECT * FROM (SELECT top 5 tb.* from ' + TableName + ' as tb
) AS PivotData
PIVOT (COUNT(' + Columns +') FOR ' + Columns +' IN ( ' + CColumns + ') ) AS PivotTable'
///Above Columns and CColumns and TableName are the local variables which are picked from temp table
Instead of "TableName" value you need to pass your table name
Instead of "Columns" On which column(ex: ID,Reference No or any column etc....) you need to perform operation
Instead of "CColumns" you have to pass your own values ex: if your checking for branch count you need to pass branch name values i.e: branch1, branch2, branch3
If you have any doubts please let me know.
Result :
=======
=========
SELECT branch1,branch2,Name,Id FROM (SELECT top 5 tb.* from Users as tb
) AS PivotData
PIVOT (COUNT(Location) FOR Branch IN (branch1,branch2) ) AS PivotTabllumns
Dynamic Query:
============
'SELECT * FROM (SELECT top 5 tb.* from ' + TableName + ' as tb
) AS PivotData
PIVOT (COUNT(' + Columns +') FOR ' + Columns +' IN ( ' + CColumns + ') ) AS PivotTable'
///Above Columns and CColumns and TableName are the local variables which are picked from temp table
Instead of "TableName" value you need to pass your table name
Instead of "Columns" On which column(ex: ID,Reference No or any column etc....) you need to perform operation
Instead of "CColumns" you have to pass your own values ex: if your checking for branch count you need to pass branch name values i.e: branch1, branch2, branch3
If you have any doubts please let me know.
Result :
=======
Thursday, June 28, 2012
Displaying a context menu for Column Headers of an AspxGridView
It is possible we can create context menu on aspxgridview. Find the following example for aspxgridview context menu.
Default.aspx:
=============
<dx:ASPxGridView ID="grvContexMenuExample" runat="server" AutoGenerateColumns="false"
KeyFieldName="ID" EnableViewState="true" ClientInstanceName="grdtest" Width="100%"
Settings-GridLines="None" OnHtmlRowPrepared="grvContexMenuExample_HtmlRowPrepared">
<ClientSideEvents ContextMenu="function(s,e) {
if(e.objectType == 'header')
{
headerContextMenu.ShowAtPos(e.htmlEvent.clientX, e.htmlEvent.clientY);
}
else if(e.objectType == 'row')
{
headerContextMenu.ShowAtPos(e.htmlEvent.clientX, e.htmlEvent.clientY);
}
}" />
<Columns>
<%--Your columns goes here--%>
<columns>
</dx:ASPxGridView>
<!--Start New Context Menu !-->
<dx:ASPxPopupMenu ID="mnContextMenu" runat="server" ClientInstanceName="headerContextMenu"
EnableAnimation="false" PopupHorizontalAlign="OutsideRight" PopupVerticalAlign="TopSides"
PopupAction="RightMouseClick">
<Items>
<dx:MenuItem Text="New Context Menu1">
</dx:MenuItem>
</Items>
<ClientSideEvents ItemClick="ContextMenuItemClick" />
</dx:ASPxPopupMenu>
<!--End New Context Menu !-->
Default.aspx.cs:
================
protected void grvContexMenuExample_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
{
if (e.RowType == GridViewRowType.Data)
if (e.RowType == GridViewRowType.Header)
{
e.Row.Attributes.Remove("oncontextmenu");
}
}
Wednesday, June 20, 2012
How to Convert Stream/Xml To DataSet/Datatable
public static DataSet GetDatasetFromExcel(string FileName)
{
bool hasHeaders = true;
string HDR = hasHeaders ? "Yes" : "No";
string strConn;
if (FileName.Substring(FileName.LastIndexOf('.')).ToLower() == ".xlsx")
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName + ";Extended Properties=\"Excel 12.0;HDR=" + HDR + ";IMEX=0\"";
else
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileName + ";Extended Properties=\"Excel 8.0;HDR=" + HDR + ";IMEX=0\"";
DataSet output = new DataSet();
using (OleDbConnection conn = new OleDbConnection(strConn))
{
conn.Open();
DataTable schemaTable = conn.GetOleDbSchemaTable(
OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
foreach (DataRow schemaRow in schemaTable.Rows)
{
string sheet = schemaRow["TABLE_NAME"].ToString();
if (!sheet.EndsWith("_"))
{
try
{
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + sheet + "]", conn);
cmd.CommandType = CommandType.Text;
DataTable outputTable = new DataTable(sheet);
output.Tables.Add(outputTable);
new OleDbDataAdapter(cmd).Fill(outputTable);
}
catch (Exception ex)
{
throw new Exception(ex.Message + string.Format("Sheet:{0}.File:F{1}", sheet, FileName), ex);
}
}
}
}
return output;
}
{
bool hasHeaders = true;
string HDR = hasHeaders ? "Yes" : "No";
string strConn;
if (FileName.Substring(FileName.LastIndexOf('.')).ToLower() == ".xlsx")
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName + ";Extended Properties=\"Excel 12.0;HDR=" + HDR + ";IMEX=0\"";
else
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileName + ";Extended Properties=\"Excel 8.0;HDR=" + HDR + ";IMEX=0\"";
DataSet output = new DataSet();
using (OleDbConnection conn = new OleDbConnection(strConn))
{
conn.Open();
DataTable schemaTable = conn.GetOleDbSchemaTable(
OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
foreach (DataRow schemaRow in schemaTable.Rows)
{
string sheet = schemaRow["TABLE_NAME"].ToString();
if (!sheet.EndsWith("_"))
{
try
{
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + sheet + "]", conn);
cmd.CommandType = CommandType.Text;
DataTable outputTable = new DataTable(sheet);
output.Tables.Add(outputTable);
new OleDbDataAdapter(cmd).Fill(outputTable);
}
catch (Exception ex)
{
throw new Exception(ex.Message + string.Format("Sheet:{0}.File:F{1}", sheet, FileName), ex);
}
}
}
}
return output;
}
Tuesday, June 19, 2012
How to convert object[] to List
List<string> fields = values.Select(i => i.ToString()).ToList();
Subscribe to:
Posts (Atom)
