Thursday, February 9, 2012

The ‘Microsoft.ACE.OLEDB.12.0′ provider is not registered on the local machine

Back a few years ago, before Microsoft Office 2010, life was a little easier for developers: Office was 32-bit, period.

As you know our days just got a little more complicated since that with Microsoft Office 2010, users can also install a 64-bit native version of Office as well.

This means to us developers that our 32-bit applications using an OLEDB Provider to access Excel or Access files might not work anymore since the 32-bit provider might not exist on a 64-bit Office 2010 installation.

In such cases, even though the user has a valid installation of Microsoft Office 2010 installed on his machine, your application might get an error as:

The ‘Microsoft.ACE.OLEDB.12.0′ provider is not registered on the local machine.

Well to address such problems Microsoft released a new redistributable named the “Microsoft Access Database Engine 2010 Redistributable”. This redistributable provides a 32-bit or a 64-bit version of the Microsoft ACE OLEDB Provider which can be downloaded here:

http://www.microsoft.com/downloads/en/details.aspx?familyid=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=en

So if as a developer you have a 32-bit application using this OLEDB provider on a machine with a 64-bit installation of Office 2010 (such as the CodeFluent Entities Access Importer), you’ll need to install the 32-bit version of the provider.

Install Tip

Launching the install of a Microsoft ACE OLEDB Provider on a machine with an Office install other than the current one (e.g. 32 on 64) will cause the install to fail. To have it run properly you need to launch it from a command line with the “/passive” argument specified.

To install the Microsoft ACE OLEDB Provider 32-bit on a machine running Office 2010 64-bit:

$> AccessDatabaseEngine.exe /passive

To install the Microsoft ACE OLEDB Provider 64-bit on a machine running Office 2010 32-bit:

$> AccessDatabaseEngine_X64.exe /passive

REF:http://blog.codefluententities.com/2011/01/20/microsoft-access-database-engine-2010-redistributable/

Wednesday, August 18, 2010

UltraWebGrid Check All/UnCheck ALL

function iggrdGridKitMgmt_ColumnHeaderClickHandler(gridName, columnId, button)
{
// debugger;
var myCol = igtbl_getColumnById(columnId);
var myGrid = igtbl_getGridById(gridName);

if(myCol.Key != "ChkAll" && myCol.Key != "Uncheck All")
{

return;
}
if (myCol.Key == "ChkAll")
{


for (i = 0; i < myGrid.Rows.length; i++)
{

myGrid.Rows.getRow(i).getCellFromKey("ChkAll").setValue(1);

}
myCol.Key = "Uncheck All";
myCol.HeaderText= "Uncheck All";
}
else
{
for (i = 0; i < myGrid.Rows.length; i++)
{


myGrid.Rows.getRow(i).getCellFromKey("Uncheck All").setValue(0);

}
myCol.Key = "ChkAll";
myCol.HeaderText = "Check All";
}
}
//If template Column and inside we have check box
function iggrdGridKitMgmt_ColumnHeaderClickHandler(gridName, columnId, button)
{
//debugger;



var myCol = igtbl_getColumnById(columnId);
var myGrid = igtbl_getGridById(gridName);

if(myCol.Key != "ChkAll" && myCol.Key != "UncheckAll")
{

return false ;
}
if (myCol.Key == "ChkAll")
{


for (i = 0; i < myGrid.Rows.length; i++)
{
myGrid.Rows.getRow(i).getCellFromKey("ChkAll").getElement('chkSelect').all[0].checked=true;
}
myCol.Key = "UncheckAll";
myCol.HeaderText= "Uncheck All";
}
else
{
for (i = 0; i < myGrid.Rows.length; i++)
{
myGrid.Rows.getRow(i).getCellFromKey("UncheckAll").getElement('chkSelect').all[0].checked=false;
myGrid.Rows.getRow(i).getCellFromKey("UncheckAll").Column.Selected = false ;
}
myCol.Key = "ChkAll";
myCol.HeaderText = "Check All";
}
return false ;
}

Thursday, June 17, 2010

DataTable to CSV

private void exportDataTableToCsv(DataTable formattedDataTable, string filename)
{
DataTable toExcel = formattedDataTable.Copy();
HttpContext context = HttpContext.Current;
context.Response.Clear();

foreach (DataColumn column in toExcel.Columns)
{
context.Response.Write(column.ColumnName + ",");
}

context.Response.Write(Environment.NewLine);
foreach (DataRow row in toExcel.Rows)
{
for (int i = 0; i < toExcel.Columns.Count; i++)
{
context.Response.Write(row[i].ToString().Replace(",", string.Empty) + ",");
}

context.Response.Write(Environment.NewLine);
}

context.Response.ContentType = "text/csv";
context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + ".csv");
context.Response.End();
}

Wednesday, June 2, 2010

Apply Styles for row - GridView

protected void grdTemp_RowDataBound(object sender, GridViewRowEventArgs e)
{

//Apply Styles for Header
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[17].Text == "RepeatHeader")
{
e.Row.BackColor = System.Drawing.Color.FromName("#003366");
e.Row.ForeColor = System.Drawing.Color.White;

}
}

Tuesday, June 1, 2010

Format Currency

double dblAmt;
string curCulture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
System.Globalization.NumberFormatInfo currencyFormat = new System.Globalization.CultureInfo(curCulture).NumberFormat;
currencyFormat.CurrencyNegativePattern = 1;

if (dsCash.Tables[0].Rows[0]["Amount"].ToString().Trim() != "")

{
dblAmt = Convert.ToDouble(dsCash.Tables[0].Rows[0]["Amount"].ToString());
lblCashAlternatives.Text = dblAmt.ToString("c", currencyFormat);
}
else
{
lblCashAlternatives.Text = "$0.0";
}

Saturday, May 15, 2010

Send Mail in C#

using System.Net.Mail;

MailMessage objMessage = new MailMessage();

objMessage.Bcc.Add(dicInputs["Bcc"].ToString().Trim());
objMessage.From = new MailAddress(dicInputs["From"].ToString().Trim());
objMessage.To.Add(dicInputs["To"].ToString().Trim());
objMessage.Subject = dicInputs["Subject"].ToString().Trim();
objMessage.Body = dicInputs["Message"].ToString().Trim();

string[] sAttachments = null;

sAttachments = dicInputs["Attachments"].ToString().Split(',');

for (int intLoop = 0; intLoop <= sAttachments.GetUpperBound(0); intLoop++)
{
strLogOut = strLogOut + "Adding attachment '" + sAttachments[intLoop] + "'";
objMessage.Attachments.Add(new Attachment(sAttachments[intLoop]));
}


SmtpClient objClient = new SmtpClient();
objClient.Host = "";
objClient.Send(objMessage);

Thursday, May 13, 2010

Thursday, May 6, 2010

DateDiff in Months C#

private static long monthDifference(DateTime startDate, DateTime endDate)
{
long monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(monthsApart);
}

Thursday, April 29, 2010

Arraylist to String c#.net

public string toDelimitedString(string delimiter)
{

if (intAmvrrayItms > 0)
{

string[] srtArray = arrStringArray.ToArray(Type.GetType("System.String")) as string[];

return string.Join(delimiter, srtArray);
}

return null;


}

Monday, April 12, 2010

Precompiling Your Website

Visual Studio offers ASP.NET developers two different project types: Web Application Projects (WAP) and Web Site Projects (WSP). One of the key differences between these project types is that WAPs require explicit compilation whereas WSPs use automatic compilation, by default. With WAPs, you compile the web application's code into a single assembly, which is created in the website's Bin folder. Deployment entails copying the markup content (the .aspx.ascx, and .masterBin folder; the code-behind class files themselves do not need to be deployed. On the other hand, you deploy WSPs by copying both the markup pages and their corresponding code-behind classes to the production environment. The code-behind classes are compiled on demand on the web server. files) in the project, along with the assembly in the Know More

Downloading any file to the browser, ASP.Net

Click Here

Monday, March 1, 2010

Rijndael Encryption

Please see this sample code for Rijndael encryption technique:

http://www.freevbcode.com/ShowCode.Asp?ID=4520

Wednesday, February 17, 2010

SQL SERVER – How to Rename a Column Name or Table Name

Refer To this Blog:

http://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/

Friday, December 4, 2009

Don't redirect after setting a Session variable (or do it right)

A problem I see over and over again on the ASP.NET forums is the following:
In a login page, if the user and password have been validated, the page developer wants to redirect to the default page.
To do this, he writes the following code:

Session["Login"] = true;
Response.Redirect("~/default.aspx");

Well, this doesn't work. Can you see why? Yes, it's because of the way Redirect and session variables work.
When you create a new session (that is, the first time you write to a Session variable), ASP.NET sets a volatile cookie on the client that contains the session token. On all subsequent requests, and as long as the server session and the client cookie have not expired, ASP.NET can look at this cookie and find the right session.
Now, what Redirect does is to send a special header to the client so that it asks the server for a different page than the one it was waiting for. Server-side, after sending this header, Redirect ends the response. This is a very violent thing to do. Response.End actually stops the execution of the page wherever it is using a ThreadAbortException.
What happens really here is that the session token gets lost in the battle.
There are a few things you can do to solve this problem.
First, in the case of the forms authentication, we already provide a special redirect method: FormsAuthentication.RedirectFromLoginPage. This method is great because, well, it works, and also because it will return the user to the page he was asking for in the first place, and not always default. This means that the user can bookmark protected pages on the site, among other things.
Another thing you can do is use the overloaded version of Redirect:

Response.Redirect("~/default.aspx", false);
This does not abort the thread and thus conserve the session token. Actually, this overload is used internally by RedirectFromLoginPage. As a matter of facts, I would advise to always use this overloaded version over the other just to avoid the nasty effects of the exception. The non-overloaded version is actually here to stay syntactically compatible with classic ASP.
UPDATE: session loss problems can also result from a misconfigured application pool. For example, if the application pool your site is running is configured as a web farm or a web garden (by setting the maximum number of worker processes to more than one), and if you're not using the session service or SQL sessions, incoming requests will unpredictably go to one of the worker processes, and if it's not the one the session was created on, it's lost.
The solutions to this problem is either not to use a web garden if you don't need the performance boost, or use one of the out of process session providers.
More on web gardens:

http://technet2.microsoft.com/WindowsServer/en/library/f38ee1ff-bdd5-4a5d-bef6-b037c77b44101033.mspx?mfr=true
How to configure IIS worker process isolation mode:

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/26d8cee3-ec31-4148-afab-b6e089a0300b.mspx?mfr=true

Thanks to Frédéric Gareau for pointing that out.
UPDATE 2: Another thing that can cause similar problems is if your server has a name that contains underscores. Underscores are not allowed in host names by RFC 952 and may interfere with the ability to set cookies and thus to persist sessions.

Reference:Tales from the Evil Empire,Bertrand Le Roy's blog

Monday, October 26, 2009

Remove duplicates from array-Vb.net

Public Function removeDup(ByVal arrShpLn As ArrayList) As ArrayList
arrShpLn.Sort()
Dim arrShpCopy = arrShpLn.Clone()
Dim count As Integer = arrShpCopy.Count
Dim i As Integer
For i = count - 1 To 1 Step -1
If (arrShpCopy(i).ToString() = arrShpCopy(i - 1).ToString()) Then
arrShpCopy.RemoveAt(i)
End If
Next i

Return arrShpCopy

End Function

Friday, August 28, 2009

Remove a row from datatable

Below is the method to remove a row from datatable based on the conditions
Dim flag As Boolean = False
Dim dtTem As New DataTable
dtTem = dt.Clone()
dtTem.Clear()
' Dim dtrow As DataRow

For Each row As DataRow In dt.Rows
For Each col As DataColumn In dt.Columns
If row(col).ToString.Trim = "" Then
flag = True
ElseIf IsNumeric(row(col)) AndAlso CInt(row(col).ToString.Trim) = 0 Then
flag = True
Else
flag = False
Exit For
End If
Next
//If there is the data, add tht row to datatable
If flag = False Then
'dtrow = dtTem.NewRow()
'dtrow = row
dtTem.ImportRow(row)
End If
Next


Return dtTem

Thursday, August 27, 2009

Removing Columns in DataTable

http://www.codeasp.net/articles/asp.net/113/removing-columns-in-datatable-

Friday, August 21, 2009

Ajax Module Popup Box

<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="btnCancel"
TargetControlID="btnPopup" PopupControlID="pnlTrackingNr" PopupDragHandleControlID="PopupHeader"

Drag="false" BackgroundCssClass="ModalPopupBG">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlTrackingNr" Style="display: none" runat="server" HorizontalAlign="Center"
Width="300px" Height="50px" BackColor="WhiteSmoke" BorderColor="#659FD9" BorderWidth="2px" BorderStyle="solid">
<div>
<div id="PopupHeader" style="background: #91B7E7; border-color: #659FD9; color: White;">
<b>Please Confirm</b></div>
<div class="Controls">
<table id="tblWarehouses" width="100%">
<tr valign="top">
<td>
<asp:Label ID="lblWarning" runat="server" CssClass="displayfont"></asp:Label>
</td>
</tr>

<tr>
<td colspan="2">
<asp:Button ID="btnYes" Text="Yes" runat="server" CssClass="button" OnClick="btnYes_Click" />
<input id="btnCancel" type="button" class="button" value="No" />
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>