Showing posts with label shiva shankar reddy likki sharepoint cognos. Show all posts
Showing posts with label shiva shankar reddy likki sharepoint cognos. Show all posts

Thursday, February 18, 2010

Connect to a database by saving the user name and password


Connect to a database by saving the user name and password

When you use Connect to a database by saving the user name and password, Office SharePoint Designer 2007 generates a SQL-based connection string that stores the user name and password in the data source connection (a process known as SQL authentication). If your site is located on a server running Windows SharePoint Services 3.0, this is the preferred option for generating a connection string. You can also create a database connection by using a custom connection string. For more information, see the later section Connect to a database by using a custom connection string.
  1. If the Data Source Library task pane is not visible, on the Task Panesmenu, click Data Source Library.
  2. In the Data Source Library task pane, under Database Connections, clickConnect to a database.
     NOTE   If the Database Connections heading is collapsed, click the plus sign (+) to expand it.
  3. In the Data Source Properties dialog box, on the Source tab, clickConfigure Database Connection.
  4. In the Configure Database Connection dialog box, under Server Information, in the Server Name box, type the name of the server where your database resides.
  5. In the Provider Name box, do one of the following:
    • If you are connecting to an external Microsoft SQL Server 2000 database or an external Microsoft SQL Server 2005 database, clickMicrosoft .NET Framework Data Provider for SQL Server.
    • If you are connecting to an external database that is OLE DB compatible, including versions of SQL other than Microsoft SQL such as MySQL, click Microsoft .NET Framework Data Provider for OLE DB.
  6. Under Authentication, click Save this username and password in the data connection.
  7. In the User name box, type your user name.
  8. In the Password box, type your password.
  9. Click Next.
     IMPORTANT   Because SQL authentication saves the user name and password as text in the data connection, any user with permission to open the site in Office SharePoint Designer 2007 can view these credentials. A security warning informs you that the user name and password are saved as text in the data connection and that other site members can access this data source. If you want other site members to access the database by using the same user name and password, click OK. If you do not want other site members to access the database by using the same user name and password, click Cancel. If your site is located on a server running Office SharePoint Server 2007, you can talk to your server administrator about configuring Single Sign-On, and then see the later section Connect to a database by using Single Sign-On authentication.
  10. In the Database list, click the database that you want to use as a data source, and then do one of the following:
    • Click Select a table or view, click the table or saved view that you want from the list, and then click Finish.
      By using this option, you create a default query that selects all records in the table or view. However, after you click Finish, you can modify the default query by clicking FieldsFilter, and Sort in the Data Source Propertiesdialog box. For more information, see the article Create a data source query.
    • Click Specify custom Select, Update, Insert, and Delete commands using SQL or stored procedures, and then click Finish.
       NOTE   This option is available only if your administrator has turned on theEnable Update Query Support option.
      By using this option, you can create custom SQL commands. When you click Finish, the Edit Custom SQL Commands dialog box opens. In this dialog box, you can create commands and add parameters. After you create a custom SQL command, you can edit the query by clicking Edit Custom Query in the Data Source Properties dialog box. For more information, seeCreate custom SQL commands later in this article.
  11. In the Data Source Properties dialog box, click the General tab, type a name for the data source, and then click OK.
    The new database connection now appears in the Data Source Librarytask pane.
 NOTE   If you are trying to connect to an external server running SQL Server, make sure that SQL Server authentication is enabled on that server.

Create custom SQL commands


Create custom SQL commands

When you click the Specify custom Select, Update, Insert, and Delete commands using SQL or stored procedures option and then click Finish in the Configure Database Connection dialog box, the Edit Custom SQL Commands dialog box opens. In this dialog box, you can create custom SQL statements to retrieve or modify the data in a database.
There are four tabs in the Edit Custom SQL Commands dialog box, each corresponding to a common SQL command. They are:
  • Select  The SELECT command is used to retrieve data from a table.
  • Update  The UPDATE command is used to modify data in a table.
  • Insert  The INSERT INTO command is used to insert new rows into a table.
  • Delete  The DELETE command is used to delete rows from a table.
The Stored Procedure list displays all of the stored procedures that are available in the database that you are connecting to.
When the Edit Custom SQL Commands dialog box opens, any statement already applied to the data appears in the SQL Statement box. For example, if you create a database connection by clicking Select a table or view to select a table, and later you decide to edit the SELECT statement, you see the following statement in the SQL Statement box on the Select tab:
SELECT * FROM dbo.[your_table_name]
The asterisk in this statement is a wild-card character that means all. This SQL statement means select all of the fields for all of the records from this specific table. To edit the statement, click Edit Command to open the Command and Parameter Editor.
Command Parameter Editor dialog box
Edit the SQL query by typing directly in the SELECT command box.

Add SQL parameters

You can also create parameters for your SQL queries by clicking Add Parameter.
SQL parameters should be used anywhere that you might use a query string, meaning text enclosed in single quotation marks. Because using query strings in SQL statements creates a security vulnerability, SQL parameters are required in Office SharePoint Designer 2007 whenever you create an SQL statement that retrieves filtered data from a data source.
For example, Northwind Traders is a gourmet food distribution company. They store all of their business data in an SQL-based database. When they retrieve their entire product list from the products table, the resulting SQL query looks like this:
SELECT * FROM dbo.[Products]
This SQL statement retrieves all of the records in the product table. Northwind wants to retrieve a filtered list that includes only the items that are out of stock. The table includes a UnitsInStock field. Using traditional SQL, the statement that would retrieve this list looks like this:
SELECT * FROM dbo.[Products] WHERE UnitsInStock = '0'
The
'0'
in this statement is a query string. This query string should be replaced by a variable. For this example, you want to create a variable called OutOfStock. The new SQL statement looks like this:
SELECT * FROM dbo.[Products] WHERE UnitsInStock = @OutOfStock
To create the SQL statement by using the OutOfStock variable in this example, perform the following procedure:
  1. In the Command and Parameter Editor dialog box, in the SELECT command box, type the following string:
    SELECT * FROM dbo.[Products] WHERE UnitsInStock = @OutOfStock
  2. Under Parameters, click Add Parameter.
  3. The variable that you want to define is OutOfStock, so in the Name column, type OutOfStock.
  4. In the Parameter Source list, click None.
  5. Because the value that you want to match is 0, in the DefaultValue box, type0.
    Command and Paramater Editor with SQL parameter statement
  6. Click OK.
    You can now see the new SQL statement in the Edit Custom SQL Commands dialog box.
    Edit Custom SQL Commands dialog box with SQL statement
  7. Click OK again.
    In the Data Source Properties dialog box, the Edit Custom Query button appears on the Source tab.
    Data Source Properties dialog box with the Edit Custom Query button

Modify the data source properties of an existing database connection


After you configure a database connection, you can later modify the connection at any time. For example, you might want to create a new query, modify an existing one, or create a custom SQL statement.

  1. On the Task Panes menu, click Data Source Library.
  2. In the Data Source Library, click the database connection that you want to modify, and then click Properties.
    If the database connection uses a custom SQL query, the Data Source Properties dialog box looks like the one in the following illustration.
    Data Source Properties dialog box with the Edit Custom Query button
    If the database connection does not use a custom SQL query, the Data Source Properties dialog box looks like the one in the following illustration.
    Data Source Properties dialog box with the Query section
  3. In the Data Source Properties dialog box, do any of the following:
    • If there is a Query area with buttons, click those buttons to add or remove fields or to create or modify a filter or sort order.
    • If there is a Query area with buttons, click Configure Database Connection to apply a custom SQL query to the connection. After you click Configure Database Connection, click Next.
       IMPORTANT   Because SQL authentication saves the user name and password as text in the data connection, any user with permission to open the site in Office SharePoint Designer 2007 can view these credentials. A security warning informs you that the user name and password are saved as text in the data connection and that other site members can access this data source. If you want other site members to access the database by using the same user name and password, click OK. If you do not want other site members to access the database by using the same user name and password, click Cancel. If your site is located on a server running Office SharePoint Server 2007, you can talk to your server administrator about configuring Single Sign-On, and then see the later section Connect to a database by using Single Sign-On authentication.
      In the Configure Database Connection dialog box, click Specify custom Select, Update, Insert, and Delete commands using SQL or stored procedures, and then click Finish.
      The Edit Custom SQL Commands dialog box opens. In this dialog box, you can create your custom SQL statement. For more information, seeCreate custom SQL commands earlier in this article.
    • If there is an Edit Custom Query button, click it to open the Edit Custom SQL Commands dialog box, where you can add, modify, or delete custom SQL statements.