0

Hi i have used multiple layer in my web application.
my db of sql server 2008 is in other machine and stored procedure has defined there.
I want to retrive data from 1 table from db and bind with gridview as well as if i select 1 row that row should be display in other webform for editing.what to do?
pls write example code for this task

2
Contributors
1
Reply
6
Views
6 Years
Discussion Span
Last Post by Moss ali
0

Hi First Crate a Data Acess Layer and craete a method there for Storeprocedur.

public static DataSet SelectSupplierContactsBySupg_id(string supg_id)
        {
            using (SqlConnection con_contacts = ConnectionManager.GetConnection())
            {
                using (SqlDataAdapter ada_contacts = new SqlDataAdapter("sprocFilteringSupplierContactsBySupg_id", con_contacts))
                {
                    ada_contacts.SelectCommand.CommandType = CommandType.StoredProcedure;
                    ada_contacts.SelectCommand.Parameters.AddWithValue("@supg_id", supg_id);
                    DataSet ds_Contacts = new DataSet();
                    try
                    {
                        ada_contacts.Fill(ds_Contacts, "SupplierGroupContacts");
                        return ds_Contacts;
                    }
                    catch
                    {

                        throw;
                    }
                    finally
                    {
                        ds_Contacts.Dispose();
                    }
                }
            }
        }

the UI layer place a grid and bind it as following.

search = txtsearch1.Text;
        //search = txtsearch2.Text;
        DataSet ds_search = new DataSet();
        try
        {
            ds_search = SupplierGroupMergerDLL.SelectSupplierContactsBySupg_id(search);
            if (ds_search.Tables[0].Rows.Count > 0)
            {
                gvFrom.DataSource = ds_search.Tables[0];
                gvFrom.DataBind();
            }

if u mean by other webform as website then change connectionstring for that particular site.

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.