Page 322 of 754« First...102030...320321322323324...330340350...Last »

HOW TO: Return Errors and Warnings from a SQL Server Stored Procedure in ADO.NET

This article describes how to display both SQL Server
errors and warnings in ADO.NET. If you raise an error that has a severity level
of 10 or less, which is a warning, no exception is raised. This warning is not
populated into the SqlErrorCollection. Instead you must hook into the InfoMessage event of the Connection object and handle the message there.

Errors in SQL
stored procedures with a severity level of 11 through 20 throw an error in SQL
that is caught in the SqlErrorCollection. Also note that some errors that have a severity level of 11 or
greater abort the whole stored procedure.

Requirements

The following list outlines the recommended hardware, software,
network infrastructure, and service packs that are required:

  • Microsoft Visual Studio .NET installed on a compatible
    Microsoft Windows operating system
  • A SQL server with the sample Northwind database
    installed

This article assumes that you are familiar with the following
topics:

  • Visual Basic .NET
  • ADO.NET data access

Create the Project and Add the Stored Procedure in SQL Server

The following sample uses a combination of Sev 10 and Sev 11
errors to demonstrate how you can use ADO.NET to display error messages with
different severity levels. This sample also demonstrates how you can use IFELSE logic in combination with RAISERROR to provide error handling in your SQL Stored procedures.

The sample performs a simple search on the Customers table in the
SQL Server Northwind database. If one of the CustomerIDs is not found, a SEV 10
exception is raised. If both of the CustomerIDs are not found, a SEV 11
exception is raised, and the stored procedure aborts. Note that you must add a
handler to hook into the InfoMessage event of the Connection object to display errors that have a severity level of 10 or
less.

  1. Follow these steps to create a new Visual Basic Windows
    Application project:

    1. Start Visual Studio .NET.
    2. On the File menu, point to New, and then click Project.
    3. In the New Project dialog box, click Visual Basic Projects under Project Types, click Windows Application under Templates, and then click OK.
  2. In Server Explorer, configure a new data connection to the
    Northwind sample database on an available SQL Server.
  3. Expand the Northwind database node, right-click stored procedures, and then click the new stored procedure.
  4. In the code window of your stored procedure, paste the
    following stored procedure code:
    CREATE proc GetCustomers
    @CustomerID1 nvarchar (5),
    @CustomerID2 nvarchar (5)
    AS
    DECLARE @err_message nvarchar(255)
    
    --if no customers found return SEV 11 error to abort stored procedure
    IF NOT EXISTS (Select CustomerID from Customers where CustomerID = @CustomerID1 or CustomerID =  @CustomerID2)
    	BEGIN
    	SET @err_message = @CustomerID1 + ' and ' + @CustomerID2 + ' Not found raise sev 11'
    	RAISERROR (@err_message, 11,1)
    	END
    
    --if 1st customerid not found throw SEV 10 exception
    IF EXISTS (Select CustomerID from Customers where CustomerID = @CustomerID1)
    	BEGIN
    	select * from Customers where CustomerID = @CustomerID1
    	END
    ELSE
    	BEGIN
    	SET @err_message = @CustomerID1 + ' not found raise sev 10'
                 RAISERROR (@err_message,10, 1)
    	END
    
    --if 2nd customerid not found throw SEV 10 exception
    IF EXISTS (select * from Customers where CustomerID = @CustomerID2)
    	BEGIN
    	select * from Customers where CustomerID = @CustomerID2
    	END
    ELSE
    	BEGIN
    	SET @err_message = @CustomerID2 +  ' not found raise sev 10'
        	RAISERROR (@err_message,10, 1)
    	END

  5. Close the stored procedure code window, and then click Yes to save the changes.

Add Code to Display Errors and Warnings

  1. In the code window of Form1, or your Visual Basic .NET
    project, add a reference to System.Data.SQLClient by adding the following line to the top of your Form1.vb file:
    Imports System.Data.SqlClient
    					

  2. Drag 2 TextBox controls (TextBox1 and TextBox2) from the toolbox to
    Form1.
  3. Press F4 to change the Text property of TextBox1 to ALFKI.
  4. Press F4 to change the Text property of TextBox2 to ANATR.
  5. Drag a Button control (Button1) from the toolbox to Form1, and then press F4 to
    change the Text property to Search.
  6. Double-click Button1, and then add the following code to the Button1_Click event handler:

    Note You must change the User ID
    value and the password = value to the correct values before you run this
    code. Make sure that User ID has the appropriate permissions to perform this
    operation on the database.

            Try
                Dim cn As New SqlConnection("Server=servername;Database=Northwind;User Id=;Password=")
                AddHandler cn.InfoMessage, AddressOf cn_InfoMessage
    
                cn.Open()
                Dim cmd As New SqlCommand("GetCustomers")
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Connection = cn
    
                cmd.Parameters.Add(New SqlParameter("@CustomerID1", SqlDbType.NVarChar, 5))
                cmd.Parameters.Add(New SqlParameter("@CustomerID2", SqlDbType.NVarChar, 5))
    
                cmd.Parameters("@CustomerID1").Value = TextBox1.Text
                cmd.Parameters("@CustomerID2").Value = TextBox2.Text
    
                Dim myReader As SqlDataReader = cmd.ExecuteReader()
                Dim RecordCount As Integer = 0
    
                'You must check the nextresult method because there is a possiblity that the
                'stored procedure may return multiple resultsets; the NextResult method
                'positions the DataReader at the next result in the resultset if you
                'have multiple results, otherwise it will return false.
                Do
                Do while myreader.read()
                Debug.WriteLine("Found customer ID : " & myReader(0))
                Loop
                Loop While myreader.NextResult()
    
                myReader.Close()
    
            Catch SqlEx As SqlException
                Dim myError As SqlError
                            Debug.WriteLine("Errors Count:" & SqlEx.Errors.Count)
                For Each myError In SqlEx.Errors
                    Debug.WriteLine(myError.Number & " - " & myError.Message)
                Next
            End Try
    					

  7. Modify the connection string to point to the Northwind
    database on your SQL server.
  8. To display errors that have a severity level of 10 or less,
    add the following sub to handle the InfoMessage event:
        Public Sub cn_InfoMessage(ByVal sender As Object, ByVal e As System.Data.SqlClient.SqlInfoMessageEventArgs)
            Debug.WriteLine("info message event: " & e.Message)
        End Sub
    					

  9. Press CTRL+F5 to run the program. Click Button1 and notice in the Output window that you do not see CustomerIDs
    ALFKI and ANATR. To make sure that the Output window is visible, press
    CTRL+ALT+O.

Generate and Handle a SEV 10 Warning

Change the value in TextBox1 from ALFKI to
AAAAA, and then click Button1 to try to select a value that does not exist in the Customers
database. The custom error code in the stored procedure traps this scenario and
raises a SEV 10 exception. You see that a SEV 10 exception is raised and
displayed by using the InfoMessage event of the Connection object. Error messages that have a severity level of 10 or less
are treated as informational messages, and are not returned as errors or in
query results.

Generate and Handle a SEV 11 Exception

In TextBox1 change the value from ALFKI to
AAAAA, and in TextBox2, change the value from ANATR to
AAAAA, and then click Button1. This does not find both values in the Customers database, and
the stored procedure raises a SEV 11 exception. You now see the SEV 11 error in
the SQLErrorCollection with your custom error message.

For
additional information, click the article numbers below to view the articles in
the Microsoft Knowledge Base:
308049

(http://support.microsoft.com/kb/308049/EN-US/
)

HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual Basic .NET

309490

(http://support.microsoft.com/kb/309490/EN-US/
)

HOW TO: Handle Multiple Results by Using the DataReader in Visual Basic .NET

316549

(http://support.microsoft.com/kb/316549/EN-US/
)

HOW TO: Debug Stored Procedures in Visual Studio .NET

321902

(http://support.microsoft.com/kb/321902/EN-US/
)

HOW TO: Call Stored Procedures with Optional Values in ADO.NET

308051

(http://support.microsoft.com/kb/308051/EN-US/
)

PRB: Output Parameters Are Not Returned When You Run an ADO.NET Command in Visual Basic .NET

Article ID: 321903 – Last Review: October 15, 2012 – Revision: 7.0


Applies to
  • Microsoft Visual Studio .NET 2002 Professional Edition
  • Microsoft Visual Studio .NET 2003 Professional Edition
  • Microsoft ADO.NET 1.1
kbhowtomaster kbsqlclient kbsystemdata KB321903

View article:
HOW TO: Return Errors and Warnings from a SQL Server Stored Procedure in ADO.NET

How to call SQL Server stored procedures in ASP.NET by using Visual Basic .NET

This article demonstrates how to use ASP.NET and ADO.NET
with Visual Basic .NET to create and to call a Microsoft SQL Server stored
procedure with an input parameter and an output parameter.

The code
sample in this article first checks whether the stored procedure that you will
create exists in the database. If the stored procedure does not exist, the code
creates a stored procedure that takes one parameter to search the Authors table based on the last name and returns the matching rows and
number of rows that are returned in an output parameter.

This article
also demonstrates how to create a Web Form that provides a simple user
interface. The Web Form contains the following items:

  • A text box in which the user types the search
    condition.
  • A DataGrid control that displays the search results.
  • A Label control that displays the number of returned records.
  • A Button control that calls the stored procedure when the button is
    clicked.

Requirements

The following list outlines the recommended hardware, software,
network infrastructure, and service packs that are required:

  • Microsoft SQL Server version 7.0 or later
  • Microsoft Visual Studio .NET
  • Microsoft Visual Basic .NET
  • Permissions to create the stored procedure in the
    database

This article assumes that you are familiar with the following
topics:

  • SQL Server stored procedures

Create an ASP.NET Project and Add Controls

In this section, you create an ASP.NET project and build the
basic user interface. Note that these steps use Microsoft Visual Basic .NET
code. To create the project, follow these steps:

  1. Click Start, point to Programs, point to Microsoft Visual Studio .NET, and then click Microsoft Visual Studio .NET.
  2. On the Visual Studio .NET Start page, click New Project.
  3. In the New Project dialog box, click Visual Basic Projects under Project Types, and then click ASP.NET Web Application under Templates.
  4. In the Name box, type a name for your Web application, and then click OK.
  5. Add the following server controls to the Web Form, and set
    the properties as they are listed in the table:

    Collapse this tableExpand this table

    Control ID Property Text Property
    Label lblLastName Type the Author’s Last Name:
    TextBox txtLastName %
    Button btnGetAuthors Get Authors
    Label lblRowCount (Row Count)

  6. Drag a DataGrid server control from the toolbox to the Web Form, and then set the
    Name property to GrdAuthors.
  7. Right-click the grid, and then click Autoformat.
  8. Click Professional 1 for the scheme, and then click OK.

Create the GetAuthorsByLastName Stored Procedure

Use the following Transact-SQL code to create the
GetAuthorsByLastName stored procedure:

Create Procedure GetAuthorsByLastName1 (@au_lname varchar(40), @RowCount int output)
as 

select * from authors where au_lname like @au_lname; 

/* @@ROWCOUNT returns the number of rows that are affected by the last statement. */
select @RowCount=@@ROWCOUNT
				

This code includes two parameters: @au_lname and @RowCount. The
@au_lname parameter is an input parameter that obtains the search string to
perform a “like” search in the Authors table. The @RowCount parameter is an output parameter that uses
the @@ROWCOUNT variable to obtain the affected rows.

Create and Run the Stored Procedure

To access SQL Server databases, you must import the System.Data.SqlClient namespace, which provides new objects such as the SqlDataReader and the SqlDataAdapter objects. You can use SqlDataReader to read a forward-only stream of rows from a SQL Server database.
DataAdapter represents a set of data commands and a database connection that
you can use to fill the DataSet object and to update a SQL Server database.

ADO.NET
also introduces the DataSet object, which is a memory-resident representation of data that
provides a consistent, relational programming model regardless of the data
source. The code in this section uses all of these objects.

  1. Double-click the Web Form.
  2. Add the following code to the Declaration section of your
    Web Form, which appears at the top of the Code window:
    Imports System.Data
    Imports System.Data.SqlClient
    					

  3. To make sure that the stored procedure exists and to create
    a new stored procedure, use a SqlCommand object with a SqlDataReader object. You can use SqlCommand to run any SQL commands against the database. Then call the ExecuteReader method of SqlCommand to return SqlDataReader, which contains matching rows for your query.

    Add the
    following code in the Page_Load event of the Web Form:

    'Only run this code the first time the page is loaded.
    'The code inside the IF statement is skipped when you resubmit the page.
    If Not IsPostBack Then
        Dim MyConnection As SqlConnection
        Dim MyCommand As SqlCommand
        Dim MyDataReader As SqlDataReader
    
        'Create a Connection object.
        MyConnection = New SqlConnection("server=(local);database=pubs;Trusted_Connection=yes")
    
        'Create a Command object, and then set the connection.
        'The following SQL statements check whether a GetAuthorsByLastName stored procedure
        'already exists.
        MyCommand = New SqlCommand("if object_id('pubs..GetAuthorsByLastName') is not null " + "begin" + " if objectproperty(object_id('pubs..GetAuthorsByLastName'), 'IsProcedure')= 1" + " select object_id('pubs..GetAuthorsByLastName')" + " else" + " return " + "end" + " else" + " return", MyConnection)
    
        With MyCommand
            'Set the command type that you will run.
            .CommandType = CommandType.Text
    
            'Open the connection.
            .Connection.Open()
    
            'Run the SQL statement, and then get the returned rows to the DataReader.
            MyDataReader = .ExecuteReader()
    
            'If any rows are retuned, the stored procedure that you are trying
            'to create already exists. Therefore, try to create the stored procedure
            'only if it does not exist.
            If Not MyDataReader.Read() Then
                .CommandText = "create procedure GetAuthorsByLastName (@au_lname varchar(40), " & _ 
    
                                "@RowCount int output) " & _ 
    
                                " as select * from authors where au_lname like @au_lname; select @RowCount=@@ROWCOUNT"
                MyDataReader.Close()
                .ExecuteNonQuery()
            Else
                MyDataReader.Close()
            End If
    
            .Dispose()  'Dispose of the Command object.
            MyConnection.Close() 'Close the connection.
        End With
    End If
    					

  4. Call the stored procedure in the Click event of the btnGetAuthors button, and then use the SqlDataAdapter object to run your stored procedure. You must create parameters
    for the stored procedure and append it to the Parameters collection of the SqlDataAdapter object.

    Add the following code after the Page_Load event:

    Private Sub btnGetAuthors_Click(ByVal sender As System.Object, _
     ByVal e As System.EventArgs) Handles btnGetAuthors.Click
        Dim DS As DataSet
        Dim MyConnection As SqlConnection
        Dim MyDataAdapter As SqlDataAdapter
    
        'Create a connection to the SQL Server.
        MyConnection = New SqlConnection("server=(local);database=pubs;Trusted_Connection=yes")
    
        'Create a DataAdapter, and then provide the name of the stored procedure.
        MyDataAdapter = New SqlDataAdapter("GetAuthorsByLastName", MyConnection)
    
        'Set the command type as StoredProcedure.
        MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
    
        'Create and add a parameter to Parameters collection for the stored procedure.
        MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@au_lname", _
       SqlDbType.VarChar, 40))
    
        'Assign the search value to the parameter.
        MyDataAdapter.SelectCommand.Parameters("@au_lname").Value = Trim(txtLastName.Text)
    
        'Create and add an output parameter to Parameters collection.
        MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@RowCount", _
        SqlDbType.Int, 4))
    
        'Set the direction for the parameter. This parameter returns the Rows returned.
        MyDataAdapter.SelectCommand.Parameters("@RowCount").Direction = ParameterDirection.Output
    
        DS = New DataSet() 'Create a new DataSet to hold the records.
        MyDataAdapter.Fill(DS, "AuthorsByLastName") 'Fill the DataSet with the rows returned.
    
        'Get the number of rows returned, and then assign it to the Label control.
        'lblRowCount.Text = DS.Tables(0).Rows.Count().ToString() & " Rows Found!"
        lblRowCount.Text = MyDataAdapter.SelectCommand.Parameters(1).Value & " Rows Found!"
    
        'Set the data source for the DataGrid as the DataSet that holds the rows.
        Grdauthors.DataSource = DS.Tables("AuthorsByLastName").DefaultView
    
        'Bind the DataSet to the DataGrid.
        'NOTE: If you do not call this method, the DataGrid is not displayed!
        Grdauthors.DataBind()
    
        MyDataAdapter.Dispose() 'Dispose of the DataAdapter.
        MyConnection.Close() 'Close the connection.
    End Sub
    					

  5. In Solution Explorer, right-click the .aspx page, and then
    click Set as Start Page.
  6. Save the project, and then click Start in Visual Studio .NET. Notice that the project is compiled and
    that the default page runs.
  7. Type the author’s last name in the text box, and then click
    Get Author. Notice that the stored procedure is called and that the returned
    rows populate the DataGrid.

    You can provide SQL Server-type search strings such as
    G%, which returns all the authors by last names that
    start with the letter “G.”

Troubleshooting

  • If you cannot connect to the database, make sure that the ConnectionString properly points to the server that is running SQL
    Server.
  • If you can connect to the database, but if you experience
    problems when you try to create the stored procedure, make sure that you have
    the correct permissions to create stored procedures in the database to which
    you are connecting.

For more information, see the following topics in the
Microsoft .NET Framework Software Development Kit (SDK) documentation: For more information, see the following book:
Wyke, R. Allen, and Sultan Rehman and Brad Leupen. XML Programming (Core Reference)

(http://www.microsoft.com/mspress/books/sampchap/4798.aspx)

. Microsoft Press, 2001.

For more information, see the following Microsoft Training &
Certification course: For additional
information about how to perform this task by using Microsoft Active Server
Pages, click the article number below to view the article in the Microsoft
Knowledge Base:

300488

(http://support.microsoft.com/kb/300488/EN-US/
)

How To Run SQL Stored Procedures from an ASP Page

Article ID: 306574 – Last Review: October 15, 2012 – Revision: 7.0


Applies to
  • Microsoft ASP.NET 1.0
  • Microsoft ASP.NET 1.1
  • Microsoft ADO.NET 1.1
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Visual Basic .NET 2003 Standard Edition
kbhowtomaster kbsqlclient kbsystemdata KB306574

Continued here:
How to call SQL Server stored procedures in ASP.NET by using Visual Basic .NET

ASP.NET data binding overview

This article provides an introduction to ASP.NET data
binding.

For additional ASP.NET overviews, see the following
Microsoft Knowledge Base article:

305140

(http://support.microsoft.com/kb/305140/
)

ASP.NET roadmap

With ASP.NET data binding, you can bind any server control
to simple properties, collections, expressions and/or methods. When you use
data binding, you have more flexibility when you use data from a database or
other means.

This article addresses the following data binding
topics:

Data binding essentials

<%# %> Syntax

ASP.NET introduces a new declarative syntax, . This
syntax is the basis for using data binding in an .aspx page. All data binding
expressions must be contained within these characters. The following list
includes examples of simple data binding from multiple sources:

  • Simple property (syntax for a customer):
  • Collection (syntax for an order):
    
    					

  • Expression (syntax for a contact):
    <%# ( customer.First Name + " " + customer.LastName ) %>
    					

  • Method result (syntax for the outstanding balance):
    <%# GetBalance(custID) %>
    					

In the preceding examples, the inline tags
indicate where the information from a specific data source is to be placed in
the .aspx page. The following data binding example uses a TextBox Web server control:


				

For more information about data binding syntax, see the following .NET
Framework Software Development Kit (SDK) documentation:

Page.DataBind() versus Control.DataBind()

After the particular data sources have been determined and set
for the objects on the .aspx page, you must bind the data to these data
sources. You can use the Page.DataBind or the Control.DataBind method to bind the data to the data sources.

Both
methods work similarly. The main difference is that all data sources are bound
to their server controls after the Page.DataBind method is called. No data is rendered to the control until you
explicitly call either the DataBind method of the Web server control or until you invoke the
page-level Page.DataBind method. Typically, Page.DataBind (or DataBind) is called from the Page_Load event.

For more information about the DataBind method, see the following .NET Framework SDK documentation:
Control.DataBind Method
http://msdn.microsoft.com/en-us/library/w5e5992d.aspx

(http://msdn.microsoft.com/en-us/library/w5e5992d.aspx)

Data-bound list controls

The list controls are special Web server controls that can bind
to collections. You can use these controls to display rows of data in a
customized template format. All list controls expose the DataSource and the DataMember properties, which are used to bind to collections.

These controls can bind their DataSource property to any collection that supports the IEnumerable, the ICollection, or the IListSource interface.

Repeater control

The Repeater control is a templated, data-bound list. The Repeater control is “lookless;” that is, it does not have any built-in
layout or styles. Therefore, you must explicitly declare all HTML layout,
formatting, and style tags in the control’s templates.

The following
code samples demonstrate how you can use one list control, the Repeater control, to display data:

NOTE: You must modify the parameters of the connection string as
necessary for your environment.

Visual Basic .NET

<%@ Page Language="vb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>




<%# DataBinder.Eval(Container.DataItem,"au_id") %>

Visual C# .NET

<%@ Page language="c#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>




<%# DataBinder.Eval(Container.DataItem,"au_id") %>

Visual J# .NET

<%@ Page language="VJ#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

 


<%# DataBinder.Eval(Container.DataItem,"au_id") %>

For more information about the Repeater control, see the following .NET Framework SDK documentation:

DataList control

The DataList class is a feature-rich, templated, data-bound list. You can
modify the templates to customize this control. Unlike the Repeater control, DataList supports directional rendering and can optionally render in an
HTML table at run time.

For more information about the DataList control, see the following .NET Framework SDK documentation:

DataGrid control

The DataGrid control is a fully featured, multicolumn, data-bound grid. To
customize the layout of individual columns in the DataGrid, you can set the column type to “templated” and modify the
column’s templates. The DataGrid control can render without templates, which makes this control
ideal for reporting scenarios. DataGrid also supports selection, editing, deletion, paging, and sorting
by column and button columns.

For more information about the DataGrid control, see the following .NET Framework SDK documentation:

Accessing data

This section describes how to access data from a database and
bind the data to list controls. You can use the DataSet or the DataReader class to obtain data from a database.

DataSet class

A DataSet contains a complete representation of data, including the table
structure, the relationships between tables, and the ordering of the data. DataSet classes are flexible enough to store any kind of information from
a database to an Extensible Markup Language (XML) file. DataSet classes are stateless; that is, you can pass these classes from
client to server without tying up server connection resources. The following
code demonstrates how to use a DataSet to bind data to a control:

NOTE: You must modify the parameters of the connection string as
necessary for your environment.

Visual Basic .NET

Dim cnn As SqlConnection = New SqlConnection("server=(local);" & _
                                             "database=pubs;Integrated Security=SSPI")
Dim cmd As SqlDataAdapter = New SqlDataAdapter("select * from authors", cnn)
Dim ds As DataSet = New DataSet()
cmd.Fill(ds)
MyRepeater.DataSource = ds
MyRepeater.DataBind()
				

Visual C# .NET

SqlConnection cnn = new SqlConnection("server=(local);
                                       database=pubs;Integrated Security=SSPI");
SqlDataAdapter da = new SqlDataAdapter("select * from authors", cnn);
DataSet ds = new DataSet();
da.Fill(ds);
MyRepeater.DataSource = ds;
MyRepeater.DataBind();
				

Visual J# .NET

SqlConnection cnn = new SqlConnection("server=(local);
                                       database=pubs;Integrated Security=SSPI");
SqlDataAdapter da = new SqlDataAdapter("select * from authors", cnn);
DataSet ds = new DataSet();
da.Fill(ds);
MyRepeater.set_DataSource(ds);
MyRepeater.DataBind();
				

For more information about the DataSet class, see the following .NET Framework SDK documentation:

DataReader class

Conversely, if you only need to display (and not change) the data
that is to be rendered, a DataReader class may be a better solution. For example, it is better to use
a DataReader for a DropDownList control because the DataReader is a forward-only data cursor. The following code demonstrates
how to use a SqlDataReader class to bind data to a control:

Visual Basic .NET

Dim cnn As SqlConnection = New SqlConnection("server=(local);" & _
                                             "database=pubs;Integrated Security=SSPI")
Dim cmd As SqlCommand = New SqlCommand("select * from authors", cnn)

cnn.Open()
MyRepeater.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)
MyRepeater.DataBind()
				

Visual C# .NET

SqlConnection cnn = new SqlConnection("server=(local);
                                       database=pubs;Integrated Security=SSPI");
SqlCommand cmd = new SqlCommand("select * from authors", cnn);

cnn.Open();
MyRepeater.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection);
MyRepeater.DataBind();
				

Visual J# .NET

SqlConnection cnn = new SqlConnection("server=(local);
                                       database=pubs;Integrated Security=SSPI"); 

SqlCommand cmd = new SqlCommand("select * from authors", cnn); 

cnn.Open();
MyRepeater.set_DataSource(cmd.ExecuteReader(CommandBehavior.CloseConnection));
MyRepeater.DataBind();
				

For more information about the SqlDataReader class and data access with ASP.NET, see the following topics in
the .NET Framework SDK documentation:

Binding in list control templates

You can use templates in the list controls to bind and to
customize individual records of a data source. This section includes three
methods to do this.

DataBinder.Eval method

When the data source works with data that is returned from a
database, the data source may contain numerous pieces of information. You can
use the generic DataBinder.Eval method to return data. In the following code sample, the “au_id”
field is returned from the data source of the container object:

<%# DataBinder.Eval(Container.DataItem,"au_id") %>
				

For more information about the DataBinder.Eval method, see the following .NET Framework SDK documentation:

Explicit casting

If you need more control, use explicit casting. An explicit
conversion uses a type conversion keyword. These keywords act as functions, but
the compiler generates the code inline. Therefore, execution is slightly faster
than with a function call. The following code samples use explicit casting:

Visual Basic .NET

' DataTable as the DataSource
<%# CType(Container.DataItem, System.Data.DataRowView)("au_id") %>

' DataReader as the DataSource
<%# CType(Container.DataItem, System.Data.Common.DbDataRecord)("au_id") %>

' DataReader as the DataSource
<%# CType(Container.DataItem, System.Data.Common.DbDataRecord)(0) %>
				

Visual C# .NET

// DataTable as the DataSource
<%# ((System.Data.DataRowView)Container.DataItem)"au_id" %> 

// DataReader as the DataSource
<%# ((System.Data.Common.DbDataRecord)Container.DataItem)"au_id" %>

// DataReader as the DataSource
<%# ((System.Data.Common.DbDataRecord)Container.DataItem)0 %>
				

Visual J# .NET

// DataTable as the DataSource
<%# ((System.Data.DataRowView)Container.DataItem)"au_id" %> 

// DataReader as the DataSource
<%# ((System.Data.Common.DbDataRecord)Container.DataItem)"au_id" %>

// DataReader as the DataSource
<%# ((System.Data.Common.DbDataRecord)Container.DataItem)0 %>
				

Note that the preceding samples use either a DataTable, which is a subset of a DataSet, or DataReader as a data source.

ItemDataBound event

You can also use the ItemDataBound event of the control to bind the data. This event occurs when an
item is data bound to the control. The following HTML code sample defines a Repeater control with an ItemTemplate:


   
      
   

				

The following methods are required in your page:

Visual Basic .NET

public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

   'TODO: Retrieve data from a database,
   'and bind the data to a list control.

End Sub

public Sub rptr_OnItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptr.ItemDataBound
   Dim rec As DataRowView
   rec = e.Item.DataItem

   'Make sure that you have the data.
   If Not IsDBNull(rec) Then
      Dim l1 As Label
      l1 = e.Item.FindControl("lblAuthorID")
      l1.Text = rec("au_id").ToString()
   End If
End Sub
				

Visual C# .NET

public void Page_Init(object sender, System.EventArgs e)

   rptr.ItemDataBound += new RepeaterItemEventHandler(rptr_OnItemDataBound);

public void Page_Load(object sender, System.EventArgs e)

   // TODO: Retrieve data from a database,
   // and bind the data to a list control.

public void rptr_OnItemDataBound(object sender, RepeaterItemEventArgs e)

   System.Data.Common.DbDataRecord rec = (System.Data.Common.DbDataRecord)
                                          e.Item.DataItem;
   if(rec!=null) //Make sure that you have the data.

      Label l1 = (Label)e.Item.FindControl("lblAuthorID");
      l1.Text = rec"au_id".ToString();

}
				

Visual J# .NET

public void Page_Init(Object sender, System.EventArgs e)

            rptr.add_ItemDataBound(new RepeaterItemEventHandler(rptr_OnItemDataBound));

private void Page_Load(Object sender, System.EventArgs e)

            // TODO: Retrieve data from a database,
            // and bind the data to a list control.

public void rptr_OnItemDataBound(Object sender, RepeaterItemEventArgs e)

            System.Data.Common.DbDataRecord rec = (System.Data.Common.DbDataRecord)
                                                   e.get_Item().get_DataItem();
            if (rec != null) //Make sure that you have the data.

                        Label l1 = (Label)e.get_Item().FindControl("lblAuthorID");
                        l1.set_Text(((rec.get_Item("au_id")).ToString()));

}
				

See original article:
ASP.NET data binding overview

How To Hand Code an ADO Data Connection in ASP

This step-by-step procedure demonstrates how to hand code
an ActiveX Data Objects (ADO) data connection in an Active Server Pages (ASP)
page.

For the purposes of this article, the sample to follow uses the
Northwind sample database and establishes an ADO connection to both Microsoft
Access and Microsoft SQL Server 7.0 or 2000.

The Connection String

The connection string is simply a set of string values that
contain your database connection information. For example, the following string
points to the Access database:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:MydatabaseNorthwind.mdb
				

where “C:MydatabaseNorthwind.mdb” represents the source path, which
you should modify to reflect the correct path information to the Northwind
database.

The following string points to SQL Server:

Provider=SQLOLEDB;Server=Your_Server_Name;Database=Northwind; & _
UID=your_user_account;PWD=your_password;
				

where you should modify the Server, UID, and PWD parameters to reflect the correct server name, user name, and
password respectively for the database.

Putting the Connection String to Work

This section presents sample code to get a better idea of how
this works.

  1. From the Windows Start menu, point to Programs, point to Accessories, and then click Notepad.
  2. Highlight the following code, right-click the code, and
    then click Copy. In Notepad, click Paste on the Edit menu to paste the following code into Notepad:
    
    
    
    
    
    
    

    ADO Open Method

    Continue reading here:
    How to troubleshoot general printing problems in Windows 2000 when you are using Office products

    Unable to load data in the Email Router Configuration Manager

    You receive the following error when you try to load data in the Email Router Configuration Manager:

    The remote name could not be resolved ‘http’

    Incorrect values are set in the registry on the CRM server for the keys:
    • ADRootDomainScheme
    • ADSdkRootDomain
    • ADWebApplicationRootDomain

    1 . Open SQL Server management studio and run the following query on the MSCRM_CONFIG database:
    select nvarcharcolumn, columnname from DeploymentProperties


    2 . Note the values in the nvarcharcolumn for the following:

    1. ADRootDomainScheme
    2. ADSdkRootDomain
    3. ADWebApplicationRootDomain

    3. Launch Registry editor on the CRM server and check for the hive below:

    HKEY_LOCAL_MACHINESoftwareMicrosoftMSCRMADRootDomainScheme: Value should match with noted in step 2-A
    HKEY_LOCAL_MACHINESoftwareMicrosoftMSCRMADSdkRootDomain: Value should match with noted in step 2-B
    HKEY_LOCAL_MACHINESoftwareMicrosoftMSCRMADWebApplicationRootDomain: Value should match with noted in step 2-C

    If the values above do not match, then change the registry values as per the values obtained from SQL in Step 2.

    5. Perform an IISRESET on the CRM server and restart the Microsoft Email Router service.

    6 . Now launch the Email Router Configuration Manager and click Load Data on Users, Queues and Forward mailboxes.

    Article ID: 2394264 – Last Review: October 11, 2012 – Revision: 3.0


    Applies to
    • Microsoft Dynamics CRM 4.0, when used with:
      • Microsoft Dynamics CRM E-mail Router
    <% ' Remember to change the path to Northwind.mdb ' to match the location on your system. src = "C:DatabaseNorthwind.mdb" sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & src ' Uncomment the next two lines and comment the above line to switch between Access and SQL. 'sConnStr = "Provider=SQLOLEDB;Server=Your_Server_Name;Database=Northwind;" & _ '"UID=your_user_account;PWD=your_password;" 'Create and open the Connection object. Set OBJdbConn = Server.CreateObject("ADODB.Connection") OBJdbConn.Open sConnStr SQLQuery = "SELECT * FROM Customers" 'First Recordset RsCustomerList Set RsCustomerList = OBJdbConn.Execute(SQLQuery) %> <% Do While Not RScustomerList.EOF %> <% RScustomerList.MoveNext Loop RScustomerList.Close Set RScustomerList = Nothing OBJdbConn.Close Set OBJdbConn = Nothing %>
    Company Name Contact Name City State/Province
    <%= RSCustomerList("CompanyName")%> <%= RScustomerList("ContactName")%> <%= RScustomerList("City")%> <%= RScustomerList("Region")%>

  3. In Notepad, click Save on the File menu. Save the document with the file name Adopage.asp to the
    default Web site on your server, which is typically located at
    C:InetPubWwwroot.
  4. To view the page, start your Web browser, and type the HTTP
    location of the page in the Address bar. If you saved the file in the
    above-mentioned location, type http://<servername>/Adopage.asp in the Address bar.
  5. Code Explanation

    • In the preceding sample code, note the following code:
      src = "C:DatabaseNorthwind.mdb"
      sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & src
      ' Uncomment the next two lines and comment the above line to switch between Access and SQL.
      'sConnStr = "Provider=SQLOLEDB;Server=Your_Server_Name;Database=Northwind;" & _
      '"UID=your_user_account;PWD=your_password;"
      						

      This code is currently set to connect to an Access database. To connect
      to a SQL Server database, comment out the line for the Access provider and
      uncomment the SQL Server lines. To comment out a line, insert an apostrophe (‘)
      at the beginning of the line. To uncomment a line, remove the apostrophe from
      the beginning of the line. The revised code appears as follows:

      src = "C:DatabaseNorthwind.mdb"
      'sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & src
      ' Uncomment the next two lines and comment the above line to switch between Access and SQL.
      sConnStr = "Provider=SQLOLEDB;Server=Your_Server_Name;Database=Northwind;" & _
      "UID=your_user_account;PWD=your_password;"
      					

    • In the following line of code, you actually begin the
      process of creating the ADO connection:
      Set OBJdbConn = Server.CreateObject("ADODB.Connection")
      						

      Then, you execute the Open command and pass your connection string as follows:

    Troubleshooting

    When you use ADO in ASP, make sure that you:

      For more information about Microsoft Data Access Components
    (MDAC) 2.6 Software Development Kit (SDK), see the following Microsoft Web
    site:

    Article ID: 299980 – Last Review: October 12, 2012 – Revision: 4.0


    Applies to
    • Microsoft Active Server Pages 4.0
    kbaspobj kbcodesnippet kbdatabase kbhowto kbhowtomaster kbscript KB299980
    Retired KB Content Disclaimer

    This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered “as is” and will no longer be updated.

    Original post:
    How To Hand Code an ADO Data Connection in ASP

    Windows NT 4.0 and Windows 2000 disaster recovery and backup and restore procedures

    This article contains information resources for Windows NT
    4.0 and Windows 2000 disaster recovery planning and procedures, as well as
    information about Backup and Restore procedures.

    Active Directory Disaster Recovery

    General Server Disaster Recovery

    Disk Management and Backup and Restore Planning

    Other Knowledge Base Articles

    130928

    (http://support.microsoft.com/kb/130928/
    )

    Restoring a backup of Windows NT to another computer

    139822

    (http://support.microsoft.com/kb/139822/
    )

    How to restore a backup to computer with different hardware

    176014

    (http://support.microsoft.com/kb/176014/
    )

    8.3 short file names not retained after tape restore

    201068

    (http://support.microsoft.com/kb/201068/
    )

    How to set up disaster recovery for a critical WINS Server

    243204

    (http://support.microsoft.com/kb/243204/
    )

    Microsoft Distributed Transaction Coordinator (MSDTC) recovery techniques in Windows 2000 Cluster Server

    249694

    (http://support.microsoft.com/kb/249694/
    )

    How to move a Windows 2000 installation to different hardware

    250581

    (http://support.microsoft.com/kb/250581/
    )

    Windows 2000 keywords for searching the Microsoft Knowledge Base

    263532

    (http://support.microsoft.com/kb/263532/
    )

    How to perform a disaster recovery restoration of Active Directory on a computer with a different hardware configuration

    283223

    (http://support.microsoft.com/kb/283223/
    )

    Recovery of encrypted files on a server

    295932

    (http://support.microsoft.com/kb/295932/
    )

    Windows 2000 domain controllers restored with system state backups made prior to SP2 may not boot

    318715

    (http://support.microsoft.com/kb/318715/
    )

    A network adapter is missing in Device Manager after a full restore

    Article ID: 287061 – Last Review: October 12, 2012 – Revision: 5.0


    Applies to
    • Microsoft Windows 2000 Server
    • Microsoft Windows 2000 Advanced Server
    • Microsoft Windows 2000 Professional Edition
    • Microsoft Windows NT Workstation 4.0 Developer Edition
    • Microsoft Windows NT Server 4.0 Standard Edition
    • Microsoft Windows NT Server 4.0 Enterprise Edition
    • Microsoft Small Business Server 2000 Standard Edition
    • Microsoft BackOffice Small Business Server 4.0
    • Microsoft BackOffice Small Business Server 4.5
    • Microsoft BackOffice Server 2000
    • Microsoft BackOffice Server 4.0
    • Microsoft BackOffice Server 4.5
    kbbackup kbinfo w2000ntbackup KB287061

    Read the original:
    Windows NT 4.0 and Windows 2000 disaster recovery and backup and restore procedures

    How to troubleshoot general printing problems in Windows 2000 when you are using Office products

    This article describes the steps that you can use to troubleshoot printing problems in Microsoft Windows 2000 when you are using Microsoft Office products and covers the following topics:

    • General troubleshooting information
    • How to troubleshoot printing problems
    • How to troubleshoot physical problems
    • How to troubleshoot communication problems
    • How to troubleshoot Windows 2000 printing
    • How to troubleshoot common printing problems
    • Additional troubleshooting steps for printers that are connected to a network
    This article describes how to troubleshoot printing problems in Microsoft Windows 2000 when you are using Microsoft Office products.

    General troubleshooting information

    Successful troubleshooting depends on identifying the source of the problem. Printing problems occur because of trouble with the following:

    • The printing device
    • The connection between the printer and the network
    • Other printing components in Windows 2000
    • The network, protocols, and other communication components

    To solve printing problems, re-create the problem to identify the process. To determine the problem, test different scenarios. For example, if a network client cannot print to a certain printer and other users can, the problem is not with the physical printer or with the printer’s connection to the network.

    How to troubleshoot printing problems

    To solve most printing problems, use the following methods:

    • Verify that the physical printer is operational. If other users can print, the
      problem is probably not with the printer or with the print server.
    • Verify that the printer on the print server is using the correct printer driver. If print clients are using other operating systems, make sure that you installed all the drivers that are required for the other operating systems.
    • Verify that the print server is operational, make sure that there is sufficient disk space for spooling, and then make sure that the print spool service is running.
    • Verify that the client computer has the correct printer driver if print clients are using operating systems other than Windows 2000.

    How to troubleshoot physical problems

    • Check the physical printer and make sure that it is in the “ready to print” state. Print a test page from the printer console to verify the correct operation.
    • Check the cable that is connected to the printer and make sure that the cable is connected correctly. If the printer is connected directly to the network by using a network adapter, check the light on the card that indicates network connectivity.

    How to troubleshoot printer communication problems

    • Verify that you can communicate with the printer over the network. For example, if a printer communicates over TCP/IP protocol, try to ping the printer’s IP address to verify connectivity.
    • Verify that you can communicate to the print server from other computers.
    • Verify that the there are required for the printer are working, and verify that the client computer that is submitting the print job is working correctly. For example, for a Macintosh client, verify that the AppleTalk protocol is working correctly.
    • Verify that the print spool service is running on the print server.

    How to troubleshoot Windows 2000 printing

    The modularity of the printing architecture makes diagnosing problems fairly easy. Windows 2000 printing across a network includes seven processes that always occur. By testing each process, you can typically identify the problem.

    Collapse this tableExpand this table

    Process Verify each part of the process
    The administrator adds a printer and shares it.
    • Check the property of the logical printer. Make sure that the driver is correct for that printer.
    • Use the Add Printer Wizard to add another logical printer for the same physical printer to quickly identify if the problem is with the logical printer.
    • If you cannot locate network printers, or if you cannot find the printer port, you might have a network problem.
    • Verify that you are logged on as an administrator or as a member of the Administrator group.
    A network client connects to that share.
    • Check the property of the logical printer on the client computer. Make sure that the driver is correct for that printer.
    • Use the Add Printer Wizard to add another logical printer for the same physical printer to quickly identify if the problem is with the logical printer.
    • Check the user’s permissions to print to that printer, and then check the Group Policy settings for printers that are turned on.
    • If you cannot locate network printers, you might have a network problem.
    The client program creates a print job.
    • Check to see if the document that the client is trying to print includes only text or only graphics. Check the printer driver and the font settings.
    • Check to see if there is a problem with the separator page selection.
    • Try to reproduce the same print job from another client. If the print job prints correctly, the problem is probably not caused by this process.
    The client system sends the print job to the printer share on the print server.
    • Check the network transport–for example, TCP/IP, NWLink, or AppleTalk.
    • Check other network components that are required for printing–for example Print Service for Macintosh or Print Service for Unix.
    • Verify that the network is working correctly for the client. Check the network adapter and the intermediate network devices.
    • Verify that the print spool folder on the print server has not run out of disk space.
    • Try to send the print job to the spooler in another way, or from another program.
    The print server receives, spools, and alters the print job.
    • Check disk space for spooling.
    • Verify that the problem does not involve an incorrect data type, such as RAW or PScript1.
    • Try to change an EMF data type print job to the RAW data type to see if it solves the problem.
    The print server sends the print jobs to the printer.
    • Check network transport, such as TCP/IP, NWLink, NetBEUI, and other network devices.
    • Check the physical printer connection to the network.
    • Verify that the printer is ready to print.
    • Try to print from other network clients.
    The printer interprets the job and produces hardcopy output.
    • Verify that the printer is ready to print.
    • Try to print a test page from the printer console.

    How to troubleshoot common printing problems

    This section discusses general troubleshooting steps that you can use with either a local printer connected directly to the computer or with a printer that is connected to the network.

    Note For more information about network printing, see the “Additional steps for printers that are connected to the network” section.

    How to print a test page

    To print a test page, you must have Print permissions. You can also print a test page when you first install a printer.

    Note To make sure that you have Print permissions, contact your network administrator.

    To print a test page, follow these steps:

    1. Click Start, and then click Printers and Faxes.
    2. Right-click the printer that you want to test, and then click Properties.
    3. On the General tab, click Print Test Page.
    4. Click OK if the test page printed correctly.

    If the test page did not print correctly, continue troubleshooting for help resolving the printing problem.

    If you cannot print a test page, or if you cannot print in several or in all your Microsoft Windows programs, you may have one of the following problems:

    • A printer driver problem
    • A Windows problem
    • A hardware problem
    • A connectivity problem

    How to print from WordPad

    1. Start WordPad.

      To do this, click Start, point to Programs, point to Accessories, and then click WordPad.

    2. Type This is a test.
    3. On the File menu, click Print.

    If your printer prints a page that contains the words “This is a test”, the WordPad test is successful. Try to print from your program. If you cannot print from your program, or if you cannot print from several Microsoft Windows-based programs, go to the “Start Windows in Safe Mode” section.

    If you cannot print from WordPad, try to print at a command prompt.

    How to print at a command prompt

    To print at a command prompt by using a PostScript printer, follow these steps:

    1. Open a Command Prompt window.

      To do this, click Start, point to Programs, point to Accessories, and then click Command Prompt.

    2. Type copy con lpt1 at the command
      prompt, and then press ENTER.

      Note If your printer is connected to a port other than the LPT1 port, replace “lpt1″ with the correct port.

    3. Press CTRL+Z+ENTER.
    4. Type showpage at the command prompt.
    5. Press CTRL+Z+ENTER.

    If your printer prints a blank page, the connection between your computer and printer is fine.

    To print at a command prompt by using a non-PostScript printer, follow these steps:

    1. Open a Command Prompt window.

      To do this, click Start, point to Programs, point to Accessories, and then click Command Prompt.

    2. At the command prompt, type dir > lpt1 if your printer is connected to the LPT1 port.

      Note If your printer is connected to a port other than the LPT1 port, replace “lpt1″ with the correct port.

    3. Press ENTER.

    If you cannot print at a command prompt, try to start Windows in Safe Mode and then try to print at a command prompt again.

    How to start Windows 2000 in Safe Mode

    You can select from the following Safe Mode options when you start Windows 2000:

    • Safe Mode
      This option uses only the basic files and the generic drivers that are required to run Windows 2000 on your computer.
    • Safe Mode with Networking
      This option is the same as Safe Mode except that network connectivity also starts.
    • Safe Mode with Command Prompt
      This option is the same as Safe Mode except that a command prompt starts instead of Windows 2000.

    Safe Mode helps you diagnose problems. If a symptom does not re-appear when you start in Safe Mode, you can eliminate the default settings and the minimum device drivers as possible causes. If a newly added device or a changed driver is causing the problems, you can use Safe Mode to remove the device or to reverse the change.

    To start Windows 2000 in Safe Mode, follow these steps.

    Note You may want to print these instructions before you restart your computer.

    1. Click Start, and then click Shut Down.
    2. Click Restart, and then click OK.
    3. When you receive the following message, press F8:

      Please select the operating system to start.

    4. Use the arrow keys to select the appropriate Safe Mode option, and then press ENTER.

      Note The NUM LOCK key must be off before the arrow keys on the numeric keypad will function.

    5. Use the arrow keys to select an operating system, and then press ENTER.

    For additional information about Safe Mode for Windows, click the following article number to view the article in the Microsoft Knowledge Base:

    202485

    (http://support.microsoft.com/kb/202485/
    )

    Description of Safe Boot Mode in Windows 2000

    If you still cannot print at a command prompt in Safe Mode, check the cables, the switch boxes, and the connections. To do this, follow these steps:

    1. If you are connected to a switch box, try to remove the switch box, and then connect to the printer directly.
    2. Make sure that the printer is online and that it is connected.
    3. Try a self-test of the printer.

    If the self-test does not work, contact your printer manufacturer.

    How to check the printer driver

    To determine if there is a problem with your printer driver installation, remove and then reinstall your default printer driver. To do this, follow these steps:

    1. Click Start, point to Settings, and then click Printers.
    2. Right-click the default printer icon, and then click Delete.

      Note The default printer icon has a white check mark in a black circle in its upper-left corner.

    3. Click Yes to confirm that you want to delete the printer.
    4. Double-click Add Printer, and then click Next.
    5. Click Local printer, and then click Next.
    6. Click the port that you want your printer to use, and then click Next.
    7. In the Manufacturers list, click the name of your printer manufacturer.
    8. In the Printers list, click the name of your printer model.
    9. If you are not sure of the manufacturer or the model that you want, of if you do not see your printer model in the Printers list, see your printer documentation.
    10. Click Next, and then click Yes to make this your default printer.
    11. Click Next two times.
    12. Click Yes to indicate that you want to print a test page, and then click Next.
    13. Click Finish.

    Test your printer. To do this, try to print from WordPad.

    If you cannot print from WordPad after you reinstall the printer drivers, try to print by using the Generic/Text Only printer driver.

    How to install the Generic/Text Only printer driver

    The Generic/Text Only printer driver is a basic non-PostScript printer driver. Try to print by using the Generic/Text Only printer driver to determine if your printing problem is related to your printer driver.

    To do this, follow these steps:

    1. Click Start, point to Settings, and then click Printers.
    2. Double-click Add Printer, and then click Next.
    3. Click Local printer, and then click Next.
    4. Click the port that the printer is attached to, and then click Next.
    5. In the Manufacturers list, click Generic.
    6. In the Printers list, click Generic / Text Only.
    7. Click Next, and then click Yes to make this your default printer.
    8. Click Next two times.
    9. Click Yes to indicate that you want to print a test page, and then click Next.
    10. Click Finish.

    If the test page does not print, contact your printer manufacturer for more information.

    If the test page prints correctly, test your printer. To do this, try to print from WordPad.

    If you can print from WordPad, try to print from your program. If you can now print from your program, your original printer driver is incorrect or is incompatible with your system. Contact the printer manufacturer for the latest compatible drivers for your printer. You can continue to use the Generic/Text Only printer driver in the meantime, but you can only print standard black-and-white text.

    How to check the printer configuration files

    Corrupted printer configuration files can cause printing problems. Try to reinstall fresh copies of these files. To do this, follow these steps:

    1. Click Start, point to Settings, and then click Printers.
    2. Right-click the default printer icon, and then click Delete.

      Note The default printer icon has a white check mark in a black circle in its upper-left corner.

    3. Click Yes to confirm that you want to delete this printer.
    4. Open Computer Management.

      To do this, click Start, point to Settings, and then click Control Panel. Double-click Administrative Tools, and then double-click Computer Management.

    5. In the console tree, double-click System Tools, expand Services and Applications, and then click Services.
    6. In the Details pane, right-click Print Spooler, and then click Stop.
    7. In My Computer or in Microsoft Windows Explorer, delete all the files and folders in the following folder:

      C:WinntSystem32SpoolDriversW32X863

    8. If Windows is not installed on drive C in the Winnt folder, select the appropriate folder.
    9. If you cannot delete these files and folders after you stop the spooler service, or if you receive a message that states that the files are in use, follow these steps:
      1. Open Computer Management.

        To do this, click Start, point to Settings, and then click Control Panel. Double-click Administrative Tools, and then double-click Computer Management.

      2. In the console tree, double-click System Tools, expand Services and Applications, and then click Services.
      3. In the Details pane, double-click Print Spooler.
      4. On the General tab, under Startup, click Disabled, and then click OK.
      5. Restart your computer.

        You may now be able to delete the files.

    10. Open Computer Management.
    11. In the console tree, double-click System Tools, expand Services and Applications, and then click Services.
    12. In the Details pane, double-click Print Spooler.
    13. On the General tab, under Startup, click Automatic, and then click OK.

    After you update your printer files, reinstall your printer driver.

    To install a printer driver, follow these steps:

    1. Click Start, point to Settings, and then click Printers.
    2. Double-click Add Printer, and then click Next.
    3. Click Local printer, and then click Next.
    4. Click the appropriate port, and then click Next.
    5. In the Manufacturers list, click the name of your printer manufacturer.
    6. In the Printers list, click your printer, and then click Next.
    7. If you are not sure of the model or the manufacturer that you want, or if you do not see your printer model in the list of printers, see your printer documentation.
    8. Click Yes to make this your default printer, and then click Next two times.
    9. When you are prompted to print a test page, click Yes, click Next, and then click Finish.

    For a network printer, after you update the printer files, create a local port.
    To do this, follow these steps:

    1. Click Start, point to Settings, and then click Printers.
    2. Double-click Add Printer, and then click Next.
    3. Click Local printer, click to clear the Automatically detect my printer check box, and then click Next.
    4. Click Create a new port:, click Local Port, and then click Next.
    5. In the Enter a port name box, type the following text, and then click OK:

      serverprinter

      . In this example , server is the name of the printer server, and printer is the share name of the printer.

    6. In the Manufacturers list, click the name of your printer manufacturer.
    7. In the Printers list, click the name of your printer.
    8. If you are not sure of the model or the manufacturer that you want, or if you do not see your printer model in the list, see your printer documentation.
    9. Click Next, and then click Yes to make this your default printer.
    10. Click Next two times.
    11. Click Yes to indicate that you want to print a test page, and then click Next.
    12. Click Finish.

    If the test page does not print, you may have a network connectivity problem. Contact your network administrator.

    If the test page prints, your printing problem may have been caused by corrupted printer files. Set the network printer as your default printer, and then try to print from WordPad. To do this, follow these steps:

    1. Start WordPad.

      To do this, click Start, point to Programs, point to Accessories, and then click WordPad.

    2. Type This is a test.
    3. On the File menu, click Print.

    If your printer prints a page with the words “This is a test”, the WordPad test is successful.

    If the WordPad test is successful, try to print from your program. If you cannot print from the program, go to the “How to check the program” section.

    How to check the disk space

    Your computer may not have sufficient available disk space to print your document.
    To check the available space on your hard disk
    , follow these steps:

    1. Double-click My Computer.
    2. Right-click your system disk, and then click Properties.

    Note The system disk is wherever you installed Windows, typically drive C.

    A pie chart appears that indicates how much space on your disk is being used, and how much disk space is free.

    You want about 32 megabytes (MB) of free disk space to print a simple document. You may require more free disk space to print larger documents, such as documents that contain graphics. We recommend 120 MB of free disk space. Note that 1 gigabyte (GB) equals 1024 MB.
    If there is not sufficient disk space available, try to remove files and programs that you do not need. After you increase your available disk space, try to print from your program.

    How to check the program

    At this point, it has been determined that you can print from WordPad and that the printing issue seems to be specific to one program. The next set of troubleshooting steps will help you try to resolve the problem in the program. Think about what exactly the printing problem is.

    For example, does your program print graphics correctly, or are you having problems with a particular font? Does the problem occur in only one document, or in all documents in the program? As a test, try to print a blank page from the program. If this prints correctly, the program may have problems with memory or with fonts.

    To determine where the printing problem is, use the following methods:

    • Print a different, simpler file. For example, create a new document that contains only text.
    • If the document prints, try to add a graphic to the document that you just created.
    • Test different fonts to see if one of the fonts on the system is damaged.

    If the new document prints, the problem may be specific to the one document. To see if the issue is specific to something in the document, use the following methods:

    • Check the file. Save the document that you are trying to print and then paste a section of the document in a new file. If you cannot print graphics, paste one of the graphics in the new file. Close all files except the new file, and then try to print.

      If you can print your new file, your original document might require more memory than your computer has available. Your operating system might be low on memory. Try one or more of the following methods to free memory:

      • Quit any other programs that you are running
      • Close all documents except the one that you are trying to print.
      • Quit all open programs, and then restart your computer.
    • Check the fonts. If you suspect that the printing problem may be a damaged font, try to remove and then reinstall the font.

      For additional information about how to test and how to reinstall fonts, click the following article number to view the article in the Microsoft Knowledge Base:

      314960

      (http://support.microsoft.com/kb/314960/
      )

      How to install or remove a font in Windows

    Additional troubleshooting steps for printers that are connected to a network

    To help isolate and solve the problem, review the following methods:

    • Verify basic network connectivity. Check user rights, protocols, and share names to determine whether you can see the server. Try to copy a file to the server. If you cannot access the server, you might not be able to access the printer.

      On the Advanced tab, make sure that the printer availability time is correct.

      Create a local printer, and then redirect the port to the network server. Use the Add Printer wizard, click Local, and then type the server name and the printer name for the printer servernameprintername. This determines if you can copy files from the print server.

    • Check the available disk space on the print server. If there is not sufficient room to spool the print job, larger print jobs might not print where smaller print jobs do print.

      Contact your network administrator for more help.

    • Verify that you can establish a basic network connection. To do this, click Start, click Run, and then type server in the Open box.

      In this example, server is the name of the server that is sharing the printer.

      If a window opens and lists the names of the shares that are available on the server, there is a basic network connection between two computers that are sharing the printer.

      You may experience one of the following symptoms if there is no basic network connection between the two computers that are sharing the printer:

      • You receive an “Access Denied” error message.
      • You receive an “Unable to locate the server” error message.
      • A blank window appears.
    • Reinstall the printer driver. To determine if your printing problem is occurring because of a corrupted printer driver, remove and then reinstall your printer driver. To do this, follow these steps:
      1. Click Start, point to Settings, and then click Printers.
      2. Right-click the default printer icon, and then click Delete.

        Note The default printer icon has a white check mark in a black circle in its upper-left corner.

      3. Click Yes to confirm that you want to delete this printer.
      4. Double-click Add Printer, and then click Next.
      5. Click Local printer, click to clear the Automatically detect my printer check box, and then click Next.
      6. In the Port column, click a port that is already connected to your network printer, and then click Next.

        Note The port has a name that is similar to the following:

        serverprinter

        In the port name, server is the name of the printer server, and printer is the share name of the printer.

      7. If a network printer port exists, click it, and then click Next.

        If there is no network printer port, follow these steps:

        1. Click Create a new port:, select Local Port, and then click Next.
        2. In the Enter a port name box, type serverprinter. In this example, server is the name of the printer server, and printer is the share name of the printer.
      8. In the Manufacturers list, click the name of your printer manufacturer.
      9. In the Printers list, click the name of your printer, and then click Next.
      10. If you are prompted to keep the existing driver, click Replace existing driver, and then click Next.
      11. Click Yes to make this your default printer, and then click Next.
      12. If you are prompted to share this printer, click Not shared, and then click Next.
      13. Click Yes to indicate that you want to print a test page, and then click Next.
      14. Click Finish.

      Try to print from your program.

      If you can print, the printer driver that you removed from your computer was corrupted, and reinstalling it fixes the problem.

      If you cannot print, the printer driver on the server that you are connected to may be corrupted. Contact your network administrator for more help.

    • Print from a different computer. Printing from a different computer helps determine if the printing problem is specific to one computer.

      To print over the network from a different computer than the one that you typically use, log on to the network by using your user name and password. Try to print to the same printer that you are having problems printing to from the computer that you typically use.

      If you can print from a different computer, there may be a network connectivity problem between the printer and the computer that you typically use. Contact your network administrator for more help.

      If you still cannot print, try to establish a basic network connection from a different computer.

    • Establish a basic network connection. If you cannot print to the printer from another computer, see if there is a basic network connection between that computer and the printer server. To do this, follow these steps:
      1. On a different computer than the one that you typically use, log on to the network by using your user name and password.
      2. Click Start, click Run, and then type server in the Open box.

        In this example, server is the name of the print server.

      If a window opens and lists the shares that are available on the printer server, there is a basic network connection between this computer and the printer server. There may be a network connectivity problem between the printer server and the computer that you typically use, or corrupted printer driver files may have been copied from the printer server to the computer that you typically use.

      If you receive an error message or a blank window appears, your network account may not have sufficient rights to see or to print to the print server.

    • Establish a basic network connection from a different user’s computer. If a window opens on the other user’s computer and lists the shares that are available on the printer server, your own network account may not have sufficient rights to see or to print to the printer server. Contact your network administrator for more help.

      If the other user receives an error message or a blank window appears, there may be a network problem or a problem with the printer server. Contact your network administrator for more help.

    • Map a local port to the network printer share. To do this, follow these steps:
      1. Open a Command Prompt window.

        To do this, click Start, click Run, type cmd in the Open box, and then click OK.

      2. Type net use at the command prompt, and then press ENTER.
      3. If the LPT1 port is already mapped to a network share, type net use lpt1 /d at the command prompt, and then press ENTER.

        Note This command deletes the current mapping of the parallel port LPT1.

      4. Type net use lpt1:serverprinter, and then press ENTER.

        In this example, server is the name of the server, and printer is the share name of the printer.

        Notes

      If you can successfully map a local port to the network printer share, try to print from your program.

      If you can print from your program to the shared network printer, establish a persistent connection so that you can print to the network printer share after you restart Windows.

      To establish a persistent connection, follow these steps:

      1. Open a Command Prompt window.

        To do this, click Start, click Run, type cmd in the Open box, and then click OK.

      2. Type net use lpt1 /d at the command prompt to delete the current mapping of the parallel port LPT1, and then press ENTER.
      3. Type net use lpt1:serverprinter/ persistent, and then press ENTER.

        In this example, server is the computer name of the server, and printer is the share name of the printer.

        Notes

      If you still cannot print, contact your network administrator for more help.

    For additional information about how to troubleshoot problems in Windows 2000, click the following article number to view the article in the Microsoft Knowledge Base:

    281770

    (http://support.microsoft.com/kb/281770/
    )

    How to perform clean-boot troubleshooting for Windows 2000

    Article ID: 871146 – Last Review: October 12, 2012 – Revision: 5.0


    Applies to
    • Microsoft Office Publisher 2003
    • Microsoft Office PowerPoint 2003
    • Microsoft Office Outlook 2003
    • Microsoft Office OneNote 2003
    • Microsoft Office Access 2003
    • Microsoft Word 2002
    • Microsoft Publisher 2002 Standard Edition
    • Microsoft PowerPoint 2002 Standard Edition
    • Microsoft Outlook 2002 Standard Edition
    • Microsoft FrontPage 2002 Standard Edition
    • Microsoft Excel 2002 Standard Edition
    • Microsoft Access 2002 Standard Edition
    • Microsoft Word 2000
    • Microsoft Publisher 2000 Standard Edition
    • Microsoft PowerPoint 2000 Standard Edition
    • Microsoft Outlook 2000 Standard Edition
    • Microsoft FrontPage 2000 Standard Edition
    • Microsoft Excel 2000 Standard Edition
    • Microsoft Access 2000 Standard Edition
    • Microsoft Windows 2000 Server
    • Microsoft Windows 2000 Professional Edition
    • Microsoft Project 2000 Standard Edition
    • Microsoft Office Project Professional 2003
    • Microsoft Office Project Standard 2003
    • Microsoft Office Visio Professional 2003
    • Microsoft Visio 2002 Professional Edition
    • Microsoft Visio 2002 Standard Edition
    • Microsoft Project 2002 Professional Edition
    kbtshoot kbprint kbhowto KB871146

    Other Support Sites

    Community

    Get Help Now

    Article Translations

    Related Office 2000 Web Sites

    kbmbsmigrate kbsurveynew KB2394264

    See the original post:
    Unable to load data in the Email Router Configuration Manager

How to use the ASP.NET utility to encrypt credentials and session state connection strings

This step-by-step article describes how to use the
Aspnet_setreg.exe utility to encrypt credentials and session state connection
strings. Microsoft ASP.NET version 1.0 requires that you store plain text
credentials in configuration files if you want to do any of the following:

  • Change the ASP.NET worker process identity.
  • Specify an impersonation identity.
  • Specify a connection string for session state.

When you apply the hotfix that is described in Microsoft
Knowledge Base article 329250 (see “References”), you can use encrypted data
that is stored in the registry instead of plain text in the following
configuration sections:

Introduction

Use the Aspnet_setreg.exe utility to encrypt and to store these
attribute values in the registry under a secure key. Use the CryptProtectData function with the CRYPTPROTECT_LOCAL_MACHINE flag to encrypt the
credentials. Because anyone with access to the computer can call CryptUnprotectData, the encrypted data is stored under a secure registry key with a
strong discretionary access control list (DACL). When ASP.NET parses the
configuration file, it reads the secure registry key and then uses CryptUnprotectData to decrypt the data.

Inetinfo.exe, which runs under the
System identity, reads the section. To read the registry
keys that store a user name and password for the ASP.NET worker process, the
System account must have Read permission to these keys.

The ASP.NET
worker process (Aspnet_wp.exe) reads the and
sections. To read these registry keys, the worker
process account must have Read permission to these keys. If content is hosted
on a Universal Naming Convention (UNC) share, the account that is used to
access the UNC share must have permission to read these keys.

By
default, the registry keys that Aspnet_setreg.exe creates grant full control to
the System, Administrator, and Creator Owner accounts. You can use Regedt32.exe
to modify the DACL on the registry key. Make sure that arbitrary users cannot
read the registry keys.

Restart IIS

For your changes to take effect, you must restart Microsoft
Internet Information Services (IIS). By restarting IIS, you start a new ASP.NET
worker process. To do this, click Start, click
Run, type iisreset in the
Open box, and then click OK.

Note If the server that you have reconfigured is a domain controller,
you may have to restart the server.

Download and run
Aspnet_setreg.exe

The following
file is available for download from the Microsoft Download
Center:

Collapse this imageExpand this image

Download
the Aspnet_setreq.exe package now.

(http://download.microsoft.com/download/2/9/8/29829651-e0f0-412e-92d0-e79da46fd7a5/Aspnet_setreg.exe)

Release Date: April 11, 2003

For more information
about how to download Microsoft support files, click the following article
number to view the article in the Microsoft Knowledge Base:

119591

(http://support.microsoft.com/kb/119591/
)

How to obtain Microsoft support files from online services

Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help prevent
any unauthorized changes to the file.

To display all the available command-line
switches and their usage, run this tool from the command prompt without any
command-line switches. If you saved this tool to C:Tools, run the following
command from the command prompt to display all of its available switches and
help for the switches:


C:Tools>aspnet_setreg.exe

Use encrypted attributes in the configuration file

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:

322756

(http://support.microsoft.com/kb/322756/
)

How to back up and restore the registry in Windows

Note This tool creates the registry keys under the HKEY_LOCAL_MACHINE subtree. By default, only administrators can create keys under
this subtree. Make sure that you are logged on as an administrator to
successfully create these registry keys.

  1. Encrypt the userName and password attributes to be used with the section. (You can also do this for the other sections that are
    mentioned in this article). To do this, type the following command at the
    command line:

    c:Tools>aspnet_setreg.exe -k:SOFTWAREMY_SECURE_APPidentity -u:”yourdomainnameusername” -p:”password”

    This command encrypts the userName and password attributes, creates registry keys at any location that you
    specify, and then stores the attributes in those registry keys. This command
    also generates output that specifies how to change your Web.config or
    Machine.config file so that ASP.NET will use these keys to read that
    information from the registry.

    After you execute this command, you
    receive output that is similar to the following:

    Please
    edit your configuration to contain the
    following:

    userName=”registry:HKLMSOFTWAREMY_SECURE_APPidentityASPNET_SETREG,userName”
    password=”registry:HKLMSOFTWAREMY_SECURE_APPidentityASPNET_SETREG,password”

    The
    DACL on the registry key grants Full Control to System, Administrators, and
    Creator Owner.

    If you have encrypted credentials for the
    configuration section, or a connection
    string for the
    configuration section, ensure that the process identity
    has
    Read access to the registry key. Furthermore, if you have configured
    IIS to access content on a
    UNC share, the account used to access the share
    will need Read access to the registry key.
    Regedt32.exe may be used to
    view/modify registry key permissions.

    You may rename the registry
    subkey and registry value in order to prevent discovery.

  2. Modify the corresponding configuration file to point to
    these registry keys. If these values must be used in the section, the resulting section resembles the following.
    
    					

  3. Grant Read permissions to the Aspnet_wp.exe process
    account. For more information about how to change permissions for registry
    keys, see the “Use Regedt32.exe to grant permissions for the ASP.NET account on
    these registry keys” section.

Use Regedt32.exe to grant permissions for the ASP.NET account on these registry keys

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:

322756

(http://support.microsoft.com/kb/322756/
)

How to back up and restore the registry in Windows

  1. Click Start, click Run,
    type regedt32 in the Open box, and then
    click OK.
  2. Click the

    HKEY_LOCAL_MACHINESOFTWAREMY_SECURE_APP

    subkey.

  3. On the Security menu, click
    Permissions to open the Permissions dialog
    box.

    On Microsoft Windows XP or on Windows Server 2003, right-click
    the registry key, and then click Permissions.

  4. Click Add. In the dialog box that opens,
    type yourservernameASPNET(or
    yourservernameNetWork Service when using Windows
    Server 2003 (IIS 6.0)), and then click OK.
  5. Make sure that the account that you just added has Read
    permissions, and then click OK.
  6. Close Registry Editor.

For more information about a hotfix that lets you use the
features that are described in this article, click the following article number to view the article in the Microsoft Knowledge Base:

329250

(http://support.microsoft.com/kb/329250/
)

FIX: Stronger credentials for processModel, identity, and
sessionState

Note
The fix that is described in article 329250 is only available for the .NET Framework 1.0.

For more information about the Microsoft Windows
registry, click the following article number to view the article in the
Microsoft Knowledge Base:

256986

(http://support.microsoft.com/kb/256986/
)

Description of the Microsoft Windows registry

For more information about ASP.NET, click the following
article numbers to view the articles in the Microsoft Knowledge Base:

315158

(http://support.microsoft.com/kb/315158/
)

FIX: ASP.NET does not work with the default ASPNET account on a domain controller

Note
The fix that is described in article 315158 is only available for the .NET Framework 1.0.

317012

(http://support.microsoft.com/kb/317012/
)

Process and request identity in ASP.NET

Note This is a “FAST PUBLISH” article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use

(http://go.microsoft.com/fwlink/?LinkId=151500)

for other considerations.

Article ID: 329290 – Last Review: October 10, 2012 – Revision: 10.0


Applies to
  • Microsoft ASP.NET 1.1
  • Microsoft ASP.NET 1.0
kbproductlink kbdownload kbconfig kbfix kbhowtomaster kbsecurity kbstate KB329290

View article:
How to use the ASP.NET utility to encrypt credentials and session state connection strings

Year-End Closing procedures in Inventory Control in Microsoft Dynamics GP

This article discusses how to close the year and how to prepare your inventory records for the new fiscal year in Inventory Control in Microsoft Dynamics GP and in Microsoft Business Solutions – Great Plains.

Inventory year-end closing procedures

Follow these steps to close the year and to prepare your inventory records for the new fiscal year. Closing a year transfers all summarized current-year quantity (cost and sales amounts) to transaction history for the items for which you have been keeping a summarized Sales History. The Quantity Sold field for each item is set to zero. These steps also update the amount in each item’s Beginning Quantity field to the Quantity on Hand field at each site.

Additional resources

Summary steps

  1. Post all transactions for the year.
  2. Reconcile inventory quantities.
  3. Complete a physical inventory count, and then post any adjustments.
  4. Print additional reports.
  5. Make a backup.
  6. Close the year.
  7. Close the fiscal periods for the Inventory series (optional).
  8. Make a final backup.

Detailed steps

  1. Post all transactions for the year.

    Make sure that all Invoicing transactions, Sales Order Processing transactions, and Inventory transactions for the current year have been entered and then posted before you close the year. This is true so that historical information is accurate for the year you are closing, and year-to-date amounts are accurately stated for the new year. If you want to enter future-period transactions before closing the year, create a new batch that has new transactions. However, do not post the batch until after the year has been closed.

  2. Reconcile inventory quantities.

    Reconcile quantities for all items by using the Reconcile Inventory Quantities window to make sure that your Inventory Control data has not become damaged during the year. To open the Reconcile Inventory Quantities window, follow one of these steps:

    • In Microsoft Dynamics GP 2010, and Microsoft Dynamics GP 10.0, point to Tools on the Microsoft Dynamics GP menu, point to Utilities, point to Inventory, and then click Reconcile.
    • In Microsoft Dynamics GP 9.0 and in earlier versions, point to Inventory on the Utilities menu, and then click Reconcile.

    If any differences are found during the reconcile process, the quantities will be adjusted. If adjustments are made, they will be reflected on the Reconcile Report. Additionally, any serial numbers and lot numbers that were added for the adjusted items are included. If you want to change these serial numbers and lot numbers, you can use the Item Transaction Entry window. Enter decrease adjustment transactions to remove the existing serial numbers and the existing lot numbers. Then, enter increase adjustment transactions to enter the correct serial numbers and the correct lot numbers. To open the Item Transaction Entry window, point to Inventory on the Transactions menu, and then click Transaction Entry.

  3. Complete a physical inventory count, and then post any adjustments.
    1. Use the Stock Calendar Maintenance window to set up and then maintain information about when stock counts can be performed and about which days will be counted when the system calculates suggested dates for the next stock count for a specific item-site combination. To open the Stock Calendar Maintenance window, follow one of these steps:
      • In Microsoft Dynamics GP 2010 and Microsoft Dynamics GP 10.0, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Inventory, and then click Stock Calendar.
      • In Microsoft Dynamics GP 9.0 and in earlier versions, point to Setup on the Tools menu, point to Inventory, and then click Stock Calendar.
    2. The Stock Count Cycle Assignment window can be used if you want to assign one stock count frequency to many items.
      To open the Stock Count Cycle Assignment window, point to Inventory on the Cards menu, and then click Count Cycle Assignment.
    3. Create a Stock Count Schedule. A Stock Count Schedule is a list of the specific items at a specific site that will be counted during a specific count. When you start a stock count schedule, the quantity on hand for each line in the stock count schedule is captured. Later, the actual count number quantities will be compared to the captured values to create default variance transactions. Stock Count Forms can be printed during this process. To open the Stock Count Schedule window, point to Inventory on the Transactions menu, and then click Stock Count Schedule.
    4. Use the Stock Count Entry window to enter information about the results of your stock counts. When you process a stock count, variance transactions are created. If the Autopost Stock Count Variances check box is selected, the transactions will also be posted. To open the Stock Count Entry window, point to Inventory on the Transactions menu, and then click Stock Count Entry.

    Instead of following step 3, you can manually create your adjusting entries. To do this, print a Physical Inventory Checklist by using the Inventory Activity Reports window, and then perform a physical count of your Inventory Items to verify that quantity on hand amounts are accurate for all Items. To open the Inventory Activity Reports window, point to Inventory on the Reports menu, and then click Activity.

    If there are any differences, enter the necessary adjustments in the Item Transaction Entry window, and then post the transactions. To open the Item Transaction Entry window, point to Inventory on the Transactions menu, and then click Transaction Entry.

  4. Print additional reports.

    Print any additional reports that you will need for planning or for your permanent records. The suggested reports are as follows:

    • Stock Status Report
    • Purchase Receipts Report
    • Turnover Report
    • Transaction History Report
    • Serial Number List
    • Lot Number List

    To access the Reports palette, point to Inventory on the Reports menu. Use selections from the Inventory Reports palette to print these reports. If you plan to remove sold purchase receipts during the year-end closing process, we recommend that you print the Purchase Receipts Report to review the receipts that will be removed.

  5. Make a backup.

    Make a backup of all company data. This is true so that you will be able to recover quickly should a power fluctuation or other problem occur during the year-end closing procedure.

  6. Close the year.

    Closing a year performs the following tasks:

    • Transfers all summarized current-year quantity (cost and sales amounts) to transaction history for the Items for which you have been keeping summarized sales history.
    • Updates the amount in the item’s Beginning Quantity field to the Quantity on Hand field at each site. Certain reports, such as the Turnover Report, use the amount in the Beginning Quantity field for report calculations.
    • Zeros the Quantity Sold field in
      Item Quantities Maintenance window for each site.
    • Removes purchase receipts and cost change history for items that have been completely sold.
    • Removes any discontinued items from the Item records that have been completely sold.
    • Removes any lot attributes from the records of lot numbered items if they have been completely sold.
    • Updates the standard cost of each item to the current cost if you use either the FIFO periodic method or the LIFO periodic valuation method.
    • Uses the Inventory Year-End Closing window to close the year.

    The following options are available.

    • Remove discontinued items
      If you click to select the Discontinued Items check box, all discontinued Items that have a zero balance will be removed during the year-end closing process. Items can be designated as discontinued by using the Item Maintenance window. Discontinued Items that have a quantity on hand of zero (except for kit components) and have no unposted transactions will be completely removed from the Inventory module. If you use the Service Call Management module, determine whether any discontinued items exist on any unposted service documents. If discontinued items exist on any unposted service documents, the documents must be posted before you continue. The Sales Order Processing report, the Invoicing report, or the Purchase Order Processing report and inquiries will still be able to display information about these discontinued items. However, you will be unable to perform a lookup on the Item Number because it has been removed from the Item Master table. If you want to print a report or inquire on the discontinued Item, you must include the item within the Item Number range.

      Note If you select this option, you will remove the discontinued items. Additionally, you will remove all inventory history for the items. You will be unable to drill back on the inventory history for these items.

    • Remove sold receipts
      If you click to select the Sold Receipts check box, all sold receipts whose quantity received amounts and quantity sold amounts are equal will be removed. This is an optional step, and it may not be a procedure that is performed every year-end. These values may help when items are returned through Invoicing. Therefore, you may not want to remove the purchase receipts from the file.

      In Microsoft Dynamics GP 2010, Microsoft Dynamics GP 10.0 or in Microsoft Dynamics GP 9.0: Remove: Sold Receipts and Cost Change History Prior To. You click to select the Sold Receipts and Cost Change History Prior To check box to remove all sold purchase receipts and historical cost changes for items that use Average Perpetual, Last In, First Out (LIFO) Perpetual, or the First In, First Out (FIFO) Periodic valuation method, and then you enter a date. The sold receipts, quantity sold details, and historical cost changes with dates that come before the date that you entered will be removed.

      In Microsoft Business Solutions – Great Plains 8.0: Remove: Sold Receipts. If you click to select the Sold Receipts check box, all sold receipts whose quantity received amount and quantity sold amount are equal will be removed. This is an optional step, and it may not be a procedure that is performed every year-end. These values may help when items are returned through Invoicing. Therefore, you may not want to remove the purchase receipts from the file.

    • Remove sold lot attributes
      If you click to select the Sold Lot Attributes check box, values for completely sold lot numbers will be removed. For example, you can remove the value red for the lot attribute Color if you have sold all lot numbered items that have been assigned the value red.
    • Update an item’s standard cost
      If you click to select the Item’s Standard Cost check box, the Standard Cost for any items that have been assigned the FIFO periodic valuation method or the LIFO periodic valuation method will be adjusted automatically to reflect each item’s current cost or the amount you most recently paid for the item.
      If you are registered for the Manufacturing module, you will be unable to select the Item’s Standard Cost check box.

      For more information, click the following article number to view the article in the Microsoft Knowledge Base:

      930998

      (http://support.microsoft.com/kb/930998/
      )

      Error message when you perform the “Inventory Year-end Closing” routine in Microsoft Dynamics GP: “Update standard costs in the Standard Cost Rollup window”

    When you have selected all the options that you want, click Process to start the year-end closing process. When the year is being closed, you will be unable to post, reconcile quantities, change valuation methods, or change decimal places for items.

  7. Close the fiscal periods for the Inventory series (optional).

    You can use the Fiscal Periods Setup window to close fiscal periods that are still open for the year. To open the Fiscal Periods Setup window, follow one of these steps:

    • In Microsoft Dynamics GP 2010 and Microsoft Dynamics GP 10.0, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Company, and then click Fiscal Periods.
    • In Microsoft Dynamics GP 9.0 and in earlier versions, point to Setup on the Tools menu, point to Company, and then click Fiscal Periods.

    This keeps transactions from accidentally being posted to the wrong period or year. Make sure that you have posted all transactions for the period and year for all modules before closing fiscal periods. If you later have to post transactions to a fiscal period you have already closed, you must return to the Fiscal Periods Setup window to reopen the period before you can post the transaction.

  8. Make a final backup.

    Make a final backup of the company data files and keep it in safe, permanent storage. This gives you a permanent record of the company’s financial position at the time that you closed the year.

Inventory year-end closing tips

  • The year-end close must be done before any transactions for the new year have been posted.
  • You have the option to select the Discontinued Items check box, the Sold Receipts check box, or the Sold Lot Attributes check box. If you select these check boxes, all items, sold receipts, and sold lot attributes that have a zero balance will be removed during the year-end closing process.
  • If you select the Update Item’s Standard Cost check box, the standard cost for any items that have been assigned the FIFO periodic valuation method or the LIFO periodic valuation method will be adjusted automatically to reflect each item’s current cost. The current cost is the amount that you most recently paid for the Item.
  • There is no Year End Closing report for Inventory.

Inventory year-end frequently asked questions

Q1: How is the average cost of an item updated throughout the year and during the year-end closing process when you use the Average Perpetual valuation method?

A1: If you are using the Average Perpetual valuation method, all receipts for each item will be averaged to determine the average cost. The year-end closing process does not change the average cost. However, it will remove the purchase receipts that have been completely sold. The next time that a receipt is entered, the average cost will be revalued with the receipts that remain in the Inventory Purchase Receipts file.

Note In Microsoft Dynamics GP 9.0, enhancements were made to the calculation of the average cost.

For more information about the calculation of average costs, click the following article number to view the article in the Microsoft Knowledge Base:

923960

(http://support.microsoft.com/kb/923960/
)

Enhancements made to the calculation of average cost in Microsoft Dynamics GP 9.0

Q2: Can the Inventory Year-End Closing window be used throughout the year to update the standard cost of items if you use the Periodic valuation method?

A2: We do not recommend this because the Beginning Quantity field is updated during the year-end closing process. This would make that field incorrect on reports such as the Turnover report. In addition, all summary sales history information would be incorrectly moved to the following year.

Q3: What is the effect of doing a late inventory year-end close in Great Plains?

A3: Year-end closing for this module is optional.

In summary, the fields that are updated during year-end closing are mainly used in reports for quantity summaries. If these fields are not important, you may decide not to run year-end closing.

The inventory year-end close moves the summary history information from the current year to last year (as seen under Cards/Inventory/History), and zeroes out the current year information.

We recommended that you close the inventory module before you post sales and purchase transactions in the new year because, if you do this, the item’s history numbers will not be accurate (as seen under Cards/Inventory/History.) Also, the Inventory Turnover Report may not be accurate, because the item’s beginning quantities for the year will not be accurate. To illustrate, say you sold 100 items in 2012. Then, you sold 10 additional items in 2013. You posted these 2013 inventory transactions. Before doing 2012 year-end close for inventory, you will have a quantity sold of 110 in 2013. After the 2012 year end close, you will have a value of 0 instead of 10 for your 2013 (Current Year) Sales Quantity and 210 for your 2012 (Last Year) Sales Quantity.

The summary windows in inventory with the specific views of calendar or fiscal year are date-sensitive. The inventory year end close process is not date-sensitive.

Article ID: 872713 – Last Review: October 9, 2012 – Revision: 12.2


Applies to
  • Microsoft Dynamics GP 2010
  • Microsoft Dynamics GP 10.0
  • Microsoft Dynamics GP 9.0
  • Microsoft Business Solutions–Great Plains 8.0, when used with:
kbhowto kbinfo kbexpertiseinter kbexpertisebeginner kbmbsmigrate KB872713

Other Support Sites

Community

Get Help Now

Article Translations

Visit site:
Year-End Closing procedures in Inventory Control in Microsoft Dynamics GP

How to set up an adjusting period in General Ledger in Microsoft Dynamics GP

This article describes how to set up an adjusting period to record adjustments that are posted to the general ledger after the year-end close process has been performed. This article describes how to do this in General Ledger in Microsoft Dynamics GP 2010, Microsoft Dynamics GP 10.0, in Microsoft Dynamics GP 9.0, and in Microsoft Business Solutions – Great Plains 8.0.

The adjusting period that you set up should meet the following conditions:

  • The adjusting period should start on the last day of the fiscal year.
  • The adjusting period should not overlap any other period dates.
To set up an adjusting period in General Ledger in Microsoft Dynamics GP, follow these steps.

Note Historical periods cannot be changed.

  1. Take one of the following actions as appropriate:

    •  In Microsoft Dynamics GP 10.0 and Microsoft Dynamics GP 2010, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Company, and then click Fiscal Periods.
    • In Microsoft Dynamics GP 9.0 and in Microsoft Business Solutions – Great Plains 8.0, point to Setup on the Tools menu, point to Company, and then click Fiscal Periods.
  2. Set up each fiscal period. To do this, see the steps in the following example.

    Note This example assumes that the fiscal year starts on January 1 and ends on December 31 and that the fiscal year has a 13th adjusting period.

    1. In the Year list, click a year. For example, click 2012.
    2. In the First Day field, type a first day for the fiscal period. For example, type 01/01/2012.
    3. In the Last Day field, type a last day for the fiscal period. For example, type 12/31/2012.
    4. In the Number of Periods field, type the number of periods for the fiscal year. For example, type 13.
    5. Click Calculate.
    6. If it is necessary, adjust the start dates of the periods.
      In this example, type dates in the Date column beside the corresponding entry in the Period Name column as indicated in the following list:
      • Period 1: 01/01/2012
      • Period 2: 02/01/2012
      • Period 3: 03/01/2012
      • Period 4: 04/01/2012
      • Period 5: 05/01/2012
      • Period 6: 06/01/2012
      • Period 7: 07/01/2012
      • Period 8: 08/01/2012
      • Period 9: 09/01/2012
      • Period 10: 10/01/2012
      • Period 11: 11/01/2012
      • Period 12: 12/01/2012
      • Period 13: 12/31/2012
  3. Click OK.
  4. Take one of the following actions as appropriate:
    • In Microsoft Dynamics GP 10.0and Microsoft Dynamics GP 2010, point to Tools on the Microsoft Dynamics GP menu, point to Utilities, point to Financial, and then click Reconcile.
    • In Microsoft Dynamics GP 9.0 and in Microsoft Business Solutions – Great Plains 8.0, point to Utilities on the Tools menu, point to Financial, and then click Reconcile.
  5. Click to select the Year check box.
  6. Click Reconcile. Microsoft Dynamics GP reconciles the account summary data to the account detail data for all general ledger accounts.

Article ID: 871679 – Last Review: October 9, 2012 – Revision: 4.1


Applies to
  • Microsoft Dynamics GP 2010
  • Microsoft Dynamics GP 10.0
  • Microsoft Dynamics GP 9.0
  • Microsoft Business Solutions–Great Plains 8.0, when used with:
kbhowto kbexpertiseinter kbexpertisebeginner kbmbsmigrate KB871679

Read More:
How to set up an adjusting period in General Ledger in Microsoft Dynamics GP

Page 322 of 754« First...102030...320321322323324...330340350...Last »

Recent Comments

    Archives

    Categories