Google

Thursday, December 15, 2011

Hard Drvie - Error Checking

Right click drive (c drive) - properties - tools - error checking - select Automatically fix file system errors and Scan for an attempt recover of bad sectors. Reboot.

Monday, December 5, 2011

MS Access Truncate decimal values

MS Access Truncate decimal values
INT(3.9) ==> 3
INT(3.1) ==> 3

Wednesday, November 30, 2011

Tuesday, November 29, 2011

MSSQL ERROR: SQL Server Alert System: 'Demo: Sev. 24 Errors' occurred on \\DatabaseName

ALTER DATABASE DatabaseName
SET single_user WITH ROLLBACK IMMEDIATE;
go
DBCC checkdb ('DatabaseName', repair_allow_data_loss);
go


DBCC CHECKDB

ALTER DATABASE DatabaseName
SET MULTI_USER
GO

MSSQL ERROR - Arithmetic overflow error converting numeric to data type numeric

ERROR - Arithmetic overflow error converting numeric to data type numeric
 

CONVERT (decimal(5 , 2), 1) / CONVERT (decimal(5 , 2), myField)
the error typically occurs when you are trying to pass a numeric value that is too large...
CONVERT (decimal(10 , 2), 1) / CONVERT (decimal(10 , 2), myField) ==Fixed

MS Access Overflow error

- conver number to double or currency CDbl(number) CCur(number) CLng(number)
- make sure there is no division by zero

MS Access Error The field is too small to accept the amount of data you attempted to add - check nulls (nz)

The field is too small to accept the amount of data you attempted to add - check nulls (nz)

Operation must use an updateable query
If updating from a query. 
Create make table query, then update from that table.

MSSQL ERROR 9002 LOG FILE IS FULL

MSSQL 2008
use master
DBCC SQLPERF( LOGSPACE )  - this will show list of databases and log file size

use DatabaseThatHasLogFull
DBCC SHRINKFILE(DatabaseThatHasLogFull_log, 1)
BACKUP LOG DatabaseThatHasLogFull TO DISK = 'C:\AnyFileName.bak'
DBCC SHRINKFILE(DatabaseThatHasLogFull_log, 1)



MSSQL 2000
use master
DBCC SQLPERF( LOGSPACE ) 

DBCC SHRINKFILE(pubs_log, 2)
BACKUP LOG pubs WITH TRUNCATE_ONLY
DBCC SHRINKFILE(pubs_log,2)

Monday, November 28, 2011

Error Unable to Start Debugging on the Web Server

In my case it is because I had to reinstall IIS
To fix open command prompt and run the following:
%windir%\Microsoft.NET\Framework\version\aspnet_regiis.exe" -i

Error ID 5000 EventType clr20r3, P1 devenv.exe, P2 9.0.21022.8, P3 47317b3d, P4 NIL, P5 NIL, P6 NIL, P7 NIL, P8 NIL, P9 NIL, P10 NIL.

Copy msmdlocal.dll and msmgdsrv.dll
from C:\Program Files\Common Files\System\Ole DB
to C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies

Visual Studio Error System.Runtime.InteropServices.COMExeption

System.Runtime.InteropServices.COMExeption
This error indicates there is something wrong wrong with IIS.  Restart, login as admin, in worst scenario - reinstall.

In my case it had something to do with permissions, I couldn't start IIS service (error Could not start IIS Admin service on Local Computer.  Error 13: The data is invalid. ) Reinstalled IIS.

Monday, November 21, 2011

Error 280 Unable to copy file "..\..\AjaxControlToolkit.Binary.NET35\fr\AjaxControlToolkit.resources.dll"

Error 280 Unable to copy file "..\..\AjaxControlToolkit.Binary.NET35\fr\AjaxControlToolkit.resources.dll" to "bin\fr\AjaxControlToolkit.resources.dll". Access to the path 'bin\fr\AjaxControlToolkit.resources.dll' is denied. ProjectName


Delete all ajax related (or all) files/folders in bin folder.
Rebuild project.
New files/folders with corrected permissions will be created.

Monday, November 14, 2011

MSSQL - TCP PORT

1433 - Default SQL port
Client ports get a random value between 1024 and 5000
Details: http://support.microsoft.com/kb/287932

MSSQL - Round Down


Round the following number 67.485000 to 67.480000
select ROUND(67.485000,2,1)

MSSQL - Clear Cashe

DBCC FREESESSIONCACHE
DBCC FREEPROCCACHE
DBCC FREESYSTEMCACHE ('ALL') WITH MARK_IN_USE_FOR_REMOVAL;

Populating DropDownList in a ListView InsertItemTemplate

Will not work
I'm using the following function to load dropdownlist on Edit ( <ItemTemplate>)

        protected void lvBackupLog_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            ListViewDataItem dataItem = (ListViewDataItem)e.Item;
            System.Data.DataRowView dv = (DataRowView)dataItem.DataItem;
            DropDownList ddlServer = (DropDownList)e.Item.FindControl("backup_server_nameDDL");
            DropDownList ddlTape = (DropDownList)e.Item.FindControl("backup_tape_nameDDL");
            if (ddlServer != null)
            {
                DataSet dsServerList = new DataSet();
                DataLib.BackOffice_Open();
                BackOffice.aGetServerList(ref DataLib, ref dsServerList);
                DataLib.BackOffice_Close();
                ddlServer.DataSource = dsServerList;
                ddlServer.DataTextField = "backup_server_name";
                ddlServer.DataValueField = "backup_server_id";
                ddlServer.SelectedValue = dv.Row["backup_server_id"].ToString();
                ddlServer.DataBind();
            }
        }

It will populate DropDownList and will select correct items

To make it work for InsertItemTemplaet use the following
        protected void lvBackupLog_ItemCreated(object sender, ListViewItemEventArgs e)
        {
            DropDownList ddlServer = (DropDownList)e.Item.FindControl("backup_server_nameDDL");
            DropDownList ddlTape = (DropDownList)e.Item.FindControl("backup_tape_nameDDL");
            if (ddlServer != null)
            {
                DataSet dsServerList = new DataSet();
                DataLib.BackOffice_Open();
                BackOffice.aGetServerList(ref DataLib, ref dsServerList);
                DataLib.BackOffice_Close();
                ddlServer.DataSource = dsServerList;
                ddlServer.DataTextField = "backup_server_name";
                ddlServer.DataValueField = "backup_server_id";
                ddlServer.DataBind();
            }
        }
There is no need (and no way) to select item from database as this is new item.  You can of course default it to something

ASP.NET - AJAX and jQuery on the same screen

Don't use  $(document).ready(function()  as it will not work with Ajax.
Use pageLoad() instead

        function pageLoad(){
            $('#gvReport tr[class="ItemStyle"],#gvReport tr[class="AlternatingItemStyle"]')
            .bind('mouseover', function() { $(this).css('background-color', '#6E6E6E') })
            .bind('mouseout', function() { $(this).css('background-color', '') });
        }

Dynamics - GP - Error deleting batch - PM_Transaction_Open has created a duplicate key


1. Ensure no one is connected to GP
2. In Company Database select * from ..activity - no one should be connected.
3. Select * From tempdb ..DEX_SESSION - you should see record with transaction that cannot be deleted
4. Delete From tempdb ..DEX_SESSION
5. select * from ..SY00500 - you will see all uncompleted transactions, find bachnumb of the one that cannot be deleted.
6. View it (for testing purposes)
select MKDTOPST, BCHSTTUS from ..SY00500 where BACHNUMB = 'DH-110711-6'
7. Now you can delete it
update SY00500 set MKDTOPST = 0, BCHSTTUS = 0  where BACHNUMB = 'DH-110711-6'

Thursday, October 20, 2011

ASP.NET - UpdateProgress with ModalPopupExtender

Watch this example on Youtube: 
    


Add Update Progress, Modal Popup Extender and Panel with image and label

    whole code looks like:

 
    <div class="ControlsCenter">
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:ModalPopupExtender ID="modalExtender" runat="server" TargetControlID="UpdateProgress1"
            PopupControlID="Panel1" DropShadow="true" BackgroundCssClass="modalBackground">
        </asp:ModalPopupExtender>
        <asp:Panel ID="Panel1" runat="server" CssClass="modalExtender">
            <img alt="Processing" src="../Images/working.gif" />
            <br />
            <asp:Label ID="lblProcessing" runat="server" Text="Processing..." CssClass="TitleBar"></asp:Label>
        </asp:Panel>
    </div>


     Modal is executed when Update Progress is called and displays controls from Panel therefore:
     TargetControlID="UpdateProgress1"
     PopupControlID="Panel1"


    class="ControlsCenter" will center all controls
    .ControlsCenter
    {
        margin-left: auto;
        margin-right: auto;
        width: 50em;
        text-align:center;
    }


    BackgroundCssClass="modalBackground" will shadow whole screen
    .modalBackground
    {
        background-color: Gray;
        filter: alpha(opacity=50);
        opacity: 0.50;
    } 


    CssClass="modalExtender" will just centralize all controls inside
   .modalExtender
    {
        border-width: 1px;
        border-style: solid;
        background-color: #FFFFFF;
        position: absolute;
        text-align:center;
    }


    add the following javascript code just after form tag
        </form>

    <script type="text/javascript">
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(showPopup);
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(hidePopup);   

        function showPopup(sender, args){
         var ModalControl ='<%= modalExtender.ClientID %>';  
            $find(ModalControl).show();       
        }

        function hidePopup(sender, args) {
            var ModalControl ='<%= modalExtender.ClientID %>';
            $find(ModalControl).hide();
        }
    </script>

ASP.NET - Add paging

set AllowPaging="True"

and implement the following procedure

    Private Sub gvReport_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvReport.PageIndexChanging
        gvReport.PageIndex = e.NewPageIndex
        gvReport.DataSource = ds.Tables("TableName").DefaultView
        gvReport.DataBind()
    End Sub

ASP.NET - GridView - Add scrollbar and freeze header

To add scrollbar and freeze header of gridview

modify DocType <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
put your grid inside    <div id="Div1" style="OVERFLOW: auto; HEIGHT: 700px">

   <div id="Div1" style="OVERFLOW: auto; HEIGHT: 700px">
                <asp:GridView ID="gvReport" runat="server" AllowPaging="True" CssClass="dataGrid">
               


Tuesday, October 18, 2011

CSS - different align issues - align divs and controls inside div


div will start from the right, controls inside it will start from the left
<div style="float: right;">
div will start from the right, controls inside it will start from the right
<div style="float: right; text-align:right;">

Friday, October 7, 2011

MS SQL - Convert Date to Month Name and sort

Convert date to month:
DATENAME(month, TableName.DateFieldName) AS [Month Name]

Full statement with sorting by month:
 
SELECT     DATENAME(month,
TableName.DateFieldName) AS [Month Name]
FROM        
TableName
ORDER BY MONTH(
TableName.DateFieldName)



Thursday, October 6, 2011

C# - .NET - Wrong Date Format

Culture settings in visual studio for same reasons are not the same as in regional settings. In regional settings it is set to en-US and while executing the following code while running the page CultureInfo.CurrentCulture I am getting en-CA
Not sure why this is happening - couldn't find anything online, but a way around was to modify web.config
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US"/>

Thursday, September 22, 2011

Error: 'ParentTableName' is not a member of type 'EntityModel.ChildTableName' in the currently loaded schemas. Near simple identifier, line 6, column 4.

  •  MAKE sure tables are related  (primary - foreign keys are set)
  •  Note that 
it.ParentTable.Id= @SomeId - tells db to load only items that have that @SomeId
  •  MAKE sure name in where parameters is correct (usually the same as QueryStringField)
   <WhereParameters>
          <asp:QueryStringParameter Name="SomeId" QueryStringField="SomeId" Type="Int32" />
    </WhereParameters>

Wednesday, September 21, 2011

VB.NET - Excel - Hide Column

osheet.Range("L" & curLine).Columns.Hidden = True
Or
osheet.Range("H1").ColumnWidth = 0
Remember, the following line will unhide columns
osheet.Range("A" & intHeaderLine, "BH" & curLine).EntireColumn.AutoFit()

Wednesday, September 14, 2011

Error 'AsEnumerable' is not a member of 'System.Data.DataTable'

add the following reference to the project (Project/Add Reference)
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll

Friday, September 9, 2011

Error: Maximum request length exceeded

Modify Machine.Config file
Add <httpRuntime maxRequestLength="8192" /> under <system.web>


  <system.web>
<httpRuntime maxRequestLength="8192" />

Machine.config is usually located in (you may have different folder name under Framewok:
c$\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG

Friday, August 26, 2011

C# - DetailsView - Enable Inserting is missing

Go to configure data source, click advanced and then generate Insert Update Delete

Wednesday, August 24, 2011

C# Looping through listview items

' get value from the control   

    protected void Button1_Click(object sender, EventArgs e)
        {
            int x;
            string s;
            TextBox tb;
            for (x = 0; x < ListView1.Items.Count - 1; x++)
            {
                tb = (TextBox)ListView1.Items[x].FindControl("TextBox1");
                s = tb.Text.ToString();
            }
        }

Thursday, August 18, 2011

catch exception show line number

catch exception show line number
ex.StackTrace
Catch ex As Exception
            Dim strError As String = ex.StackTrace
End Try

Tuesday, July 26, 2011

Error: The referenced account is currently locked out and may not be logged on to.

home computers (windows home) cannot join the domain, may receive the following error while accessing network drive:
The referenced account is currently locked out and may not be logged on to.
go to run, execute 'control password2' and modify credentials (usually password has been expired)

Monday, July 25, 2011

Error: InstallUtil. Installlog is denied

Error: InstallUtil. Installlog is denied - Log in as administrator or right click cmd and run as administrator

Friday, July 22, 2011

MS SQL - Round Decimal Down

MSSQL - Round Down
Round the following number 67.485000 to 67.480000
select ROUND(67.485000,2,1)

Thursday, July 21, 2011

MS Access - Error: Query is too complex

divide existing query into multiple queries.  in my case I had 1 query that had union statement in it and another query that was calling the first one.  to resolve, divided first query into 2.

Wednesday, June 15, 2011

Error 1500 Windows cannot log you on because your profile cannot be loaded. Check that you are connected to the network, and that your network is functioning correctly.

Error 1500 Windows cannot log you on because your profile cannot be loaded. Check that you are connected to the network, and that your network is functioning correctly.

on server 2008 R2 when trying to log in as domain administrator
Domain administrator entry in registry was missing. 

This is how I fixed it:
Log in to another server,
 go to HKEY_LOCAL_MACHINE \ Software \ Microsoft \Windwos NT \ Current Version\ Profile list
 right click on key that belongs to domain administrator and export
 move file to the server that expierience the problem (error 1500)
 login to that server with different user name (local administrator)
 import registry key
 log in as domain administrator - problem fixed.

Saturday, June 11, 2011

Simple - How to create QR (Quick Response) barcode online for mobile devices

Go To:
http://qrcode.kaywa.com/
Under URL type the address of your website:

Click Generate! to produce the QR Code

Right click barcode and save it:


Now you have image that can be scanned by mobile devices.

More info on wiki 
mobile barcode generator

Wednesday, February 16, 2011

C# - CSS - Create Simple Wrapper

This is copy and paste example.  Create simple html page and then use stylesheet listed below.
1. In your aspx add the following <div> elements:
<body>
    <form id="form1" runat="server">
    <div id="PageWrapper">
        <div id="Header">
            Header Goes Here
        </div>
        <div id="MenuWrapper">
            Menu Goes Here
        </div>
        <div id="MainContent">
            Main Content goes here
        </div>
        <div id="Sidebar">
            Sidebar Goes Here
        </div>
        <div id="Footer">
            Footer Goes Here
        </div>
    </div>
    </form>
</body>

2.  Create css like this:
#PageWrapper
{
    width: 844px;  
}
#Header
{
    background-color: #C0C0C0;
    width: 844px;
    height: 86px;
}
#MenuWrapper
{
    width: 844px;
}
#MainContent
{
    width: 664px;
    float: left;
}

#Sidebar
{
    background-color: Gray;
    width: 180px;
    float: left;
}
#Footer
{
    background-color: #C0C0C0;
    width: 844px;
    clear: both;
}


Note that MainContent and SideBar are on the same line.
Also note that clear: both; declaration will clear left and right floats.

Tuesday, February 15, 2011

MS SQL / Visual Studio - EXPORT TABLE or VIEW with records into sql statement

In Visual Studio go to view/Server explorer.
Right click on database (you may need to create new connection if required) and select publish to provider.
Click next and select RJM BackOffice, uncheck script all objects.
Click Views then next
Select View then next
Script to file then next
Script for target database - you may need to select 2000
Next and finish.

MS SQL - Rebuild All Indexes

MS SQL - Rebuild All Indexes

Microsoft Access - Replace New Line Character

Replace(Replace([fieldName],Chr(10),""),Chr(13),"")

Microsoft Access - Stop Running Query

CTRL + Break

MS SQL - Edit more then 200 records

- select Edit top 200 records.
- right click/Pane/SQL
- modify sql (top 300) order by, etc.