Error: The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine. I got this error when I tried to run my .NET application into VS 2010 with 64 bit OS/machine, to resolve this issue we have to forcefully set application setting to run this application for 32 bit, to do that please follow the steps below 1) Right click on the project and click on the properties 2) Go to the Build tab 3) Set Platform target from "Any CPU" to x86 4) Now run your application again, you will not get this error again. |
Tuesday, June 01, 2010
Error: The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.
Sunday, March 21, 2010
Error: ASP.NET Ajax client-side framework failed to load. OR 'Sys' is undefined.
Error: ASP.NET Ajax client-side framework failed to load. OR 'Sys' is undefined. in VS 2008
Cause:
I got this error very first time when I tried to use AJAX ScriptManager object using VS2008.
I was tring to registred script using ScriptManager like below
protected void Button1_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(
this,this.GetType(),"script","alert('Hi');",true);
}
Solution:
I found there are two way to solve this error
1) You need to add httpHandlers into the web.config below "compilation" tag
Code:
<!--Ajax -->
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions,
Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httpHandlers>
<compilation debug="true">
2) You can solve this error by using RegisterAsyncPostBackControl method
Using beolw code button control will not have any page refresh like a client control.
Code:
protected void Page_Load(object sender, EventArgs e)
{
// register the Button1 control as one that can cause partial postbacks.
ScriptManager1.RegisterAsyncPostBackControl(Button1);
}
Note: I may not get this error in latest version/patch of VS2008.
Wednesday, March 10, 2010
Combo box Auto Complete Property in C# and VB using .NET
When you have a requirement for combo box control like: when user types some text/number then combo box should display/select value as per user typing the characters from keyboard.
Ex: If Combo Box having following items
ComboBox1.Items.Add("ABC123")
ComboBox1.Items.Add("AABC123")
ComboBox1.Items.Add("AAABC123")
ComboBox1.Items.Add("AAAABC123")
ComboBox1.Items.Add("CCCEF123")
ComboBox1.Items.Add("1123ABC")
ComboBox1.Items.Add("2234BCD")
ComboBox1.AutoCompleteSource = AutoCompleteSource.ListItems
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
and requirement is when user type in the combo box the relative text should display
Ex: When user type "A" then combo box should select "ABC123" value from the list
When user type "AA" then combo box should select "AABCD123" value from the list
When user type "AAA" then combo box should select "AAABC123" value from the list
etc.
To achieve above requirements, very simple in .NET to use "ComboBox1.AutoCompleteMode" property, it has 4 mode and default is "None"

3) AutoCompleteMode.SuggestAppendThis Mode will append the value as user type the characters one by one and select the nearest value in the combo box and also will open (Drop) the combo box to suggest the other nearest possible value present in the combo box
4) AutoCompleteMode.None (Default)
This Mode will select the nearest value in the combo box when user type ONLY first characher in the combo box
Tuesday, March 09, 2010
How to create ASP.NET Web Parts for Windows SharePoint Services 3.0
How to create ASP.NET Web Parts for Windows SharePoint Services 3.0
Saturday, March 06, 2010
What is “unsafe” Keyword in C#.NET
What is "unsafe" Keyword in C#.NET
In C# the value can be directly referenced to a variable, so there is no need of pointer. Use of pointer sometime crashes the application. But C# supports pointer and we can use pointer in C#.
The use of pointer in C# is defined as an unsafe code. So if we want to use pointer in C# the pointer must be present in the body of unsafe declaration. But pointer does not come under garbage collection.
Example:-
unsafe
{
int firstVariable;
int* secondPointerVariable;
firstVariable = 25;
secondPointerVariable = &firstVariable;
Console.WriteLine("secondPointerVariable = {0}", secondPointerVariable);
//returns secondPointerVariable = 25
}
Note: you may get compilation error ("Unsafe code may only appear if compiling with /unsafe") while compiling the above code.
If you' are compiling from the command line then include the /unsafe switch as the error suggests.
If you're compiling from Visual Studio, then look in your project's properties and, under the build tab, check the 'Allow unsafe code' box. It should work fine.
How to make an application offline in ASP.NET
How to make an application offline in ASP.NET
Microsoft's Internet Information Services (IIS) web server software is used to make an application offline. The IIS is instructed to route all incoming requests for the web site to another URL automatically.
Steps for application configuration:
- From IIS manager -> right-click on the application -> choose Properties.
- Choose Virtual Directory tab and indicate that the content for this application should come from "A redirection to a URL."
- Then enter the same URL to redirect in "Redirect to".
- Check the box "The exact URL entered above.
Read more way to do the same.
http://aspalliance.com/1666_How_to_Make_an_Application_Offline_in_ASPNET_20.all
Web Service Vs WCF (Window Communication Foundation)
Web Service Vs WCF (Window Communication Foundation)
WCF is a set of .NET Framework-based technologies for building and running services. WCF is the next step in the evolutionary path that started with COM, COM+, and MSMQ, and continues through .NET Remoting, ASMX, System.Messaging, and .NET Enterprise Services. WCF combines these technologies and offers a unified programming model for developing services using any CLR-compliant language.
Feature | ASP.NET Web Service | WCF |
Performance | Slower compared to WCF | The main benifit of the design of the DataContractSerializer is better performance over XML serialization |
File Extension | File extention is asmx | File extension is .svc |
Data Transformation | To and from Data Transition is done through XML Serializer | DataContractSerializer is used for data transition |
Webmethods vs DataContract Attributes | ASP.NET WebService uses Webmethods to to translate .NET FW types in to XML. | The WCF uses the DataContractAttribute and DataMemeberAttribute to translate .NET FW types in to XML. |
Limitations | Only Public fields or Properties of .NET types can be translated into XML.Only the classes which implement IEnumerable interface, ICollection interface can be serializable | Public/Private fields or properties of .NET types can be translated |
IDictionary Interface class | Classes that implement the IDictionary interface, such as Hash table can not be serialized. | The DataContractSerializer can translate the Hash Table into XML. Hence using WCF we can even translate HashTable into XML |
Know which fields /properties | XMLSerialization does not indicate the which fields or properties of the type are serialized into XML | DataCotratSerializer Explicitly shows the which fields or properties are serialized into XML |
Exception handling | In ASP.NET Web services, Unhandled exceptions are returned to the client as SOAP faults. | In WCF Services, unhandled exceptions are not returned to clients as SOAP faults. A configuration setting is provided to have the unhandled exceptions returned to clients for the purpose of debugging. |
Example | [WebService] } | [ServiceContract] |
Wednesday, February 03, 2010
Multiple rows getting selected on mouse move when I am closing ContextMenuStrip by clicking datagridview row
Multiple rows getting selected on mouse move when I am closing ContextMenuStrip by clicking datagridview row
Note: Before looking solution for this issues you have to understand how to do drag and drop from one datagridview to another, See here http://riteshk.blogspot.com/2009/06/how-to-change-mouse-icon-when-drag_23.html
This issue is related to DataGridView DragDropEffects.Move,When you open sub menu from datagridview mouse down event and you have code to activate drag drop event too then on click of datagridview row, control in activating dagDropEffects.Move and when you move the mouse after closing the sub menu, mouse cousor having same effect (Move) and it will select multiple rows on the mouse move event.
Solution
To overcome this problem we have to ignore activating "DragDropEffects.Move" by putting some condition when sub menu get pops up
In the below code I have placed one boolean flag (isSubMenuClicked) and setting true when sub menu display otherwise its false
and check if "columnIndex > -1 and isSubMenuClicked = False" then only control should go and activate the datagridview dragdrop
DataGridView MouseDoubleClick not getting fire
Another problem here on the mouse double click "DataGridView1.DoDragDrop" should not get activate, other wise datagridview mouse double click will not get fire
Solution
To overcome this problem you have to check whether mouse button clicked once or twiced for that I have placed one condition in below code
its "If e.Clicks = 1 Then"
Source Code
Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown
Dim gridColumnIndex As Integer
'Get the Index of Row which is being Dragged
'We would use this Index on Drop to identify which Row was dragged and get the values from that row
If e.Button = Windows.Forms.MouseButtons.Left Then
gridColumnIndex = DataGridView1.HitTest(e.X, e.Y).RowIndex
'For Mouse Single Click Only
If e.Clicks = 1 Then
'If Grid have any row and sub menu not display
If gridColumnIndex > -1 And isSubMenuClicked = False Then
DataGridView1.DoDragDrop(gridColumnIndex, DragDropEffects.Move)
Else
DataGridView1.ClearSelection()
End If
End If
End If
Dim hitRowIndex As Integer
hitRowIndex = DataGridView1.HitTest(e.X, e.Y).RowIndex
'Open Sun Menu only on Mouse Right click and
'Avoid sub menu to display on datagridview header click
If (e.Button = Windows.Forms.MouseButtons.Right And hitRowIndex > -1) Then
ContextMenuStrip1.Show(DataGridView1, New Point(e.X, e.Y))
isSubMenuClicked = True
Else
isSubMenuClicked = False
End If
End Sub
Thursday, December 31, 2009
How to check which version of the dotnet framework is installed
2) Type --> "%windir%\Microsoft.NET\Framework\"
You will see all the version installed folder name (Ex: v1.0.3705, v1.1.4322, v2.0.50727, v3.0, v3.5)
Friday, November 13, 2009
How to Display/Hide Crystal Report Viewer Tab and Status Bar at run time using VB.NET
How to Display/Hide Crystal Report Viewer Tab and Status Bar at run time using VB.NET I am working with Visual Studio 2005 and faced some issues while working with crystal report, my requirement is to display and hide tab and status bar control from crystal report viewer, event tab control should display customized name in the tab text. I found the way to do this, below the code in vb.net
Display/Hide crystal report viewer tab control and rename the tab control ''' <summary> ''' This method will make tab controls visibile True/False ''' </summary> ''' <remarks>Ritesh</remarks> Private Sub CrystalReportViewerTab(ByVal rptViewer As CrystalDecisions.Windows.Forms.CrystalReportViewer, ByVal isVisible As Boolean) 'if tab visible If isVisible Then .ItemSize = New Size(70, 18) .SizeMode = TabSizeMode.FillToRight .Appearance = TabAppearance.Normal 'Here you can give customize name to tab .TabPages(0).Text = "My Tab Text" End With Else 'if tab hide With reportTabs .ItemSize = New Size(0, 1) .SizeMode = TabSizeMode.Fixed .Appearance = TabAppearance.Buttons End With End If End Sub
Display/Hide crystal report viewer status bar ''' This method will make status bar visibile True/False Public Sub CrystalReportViewerStatusBar(ByVal rptViewer As CrystalDecisions.Windows.Forms.CrystalReportViewer, ByVal isVisible As Boolean) Dim ctl As Control For Each ctl In rptViewer.Controls If ctl.GetType().Name.ToString() = "StatusBar" Then ctl.Visible = isVisible End If Next End Sub |