You must Sign In to post a response.
  • Category: .NET

    how to pass comma separated values to stored procedure from c#.net code - urgent

    Hi,
    I want to pass comma separated values to stored procedure(Sql Server2005) from c#.net code.

    Requirement is like i have one text box(Role), for that corresponding some rights ids are there.So I want to pass this role and associated RolesID to database and then add it to respective tables.

    Can any one send the stored procedure and needed code.



    Thanks in Advance
  • #413330
    Hi,

    create proc GetIdsProc(@Id int)as
    select * from table where id=@Id

    DARE TO BE DIFFERENT

  • #413348
    Hi

    CREATE PROCEDURE dbo.GetPeopleByLastName (@LastName NVARCHAR(50))
    AS
    SELECT ContactID,
    FirstName,
    LastName
    FROM Person.Contact
    WHERE LastName = @LastName
    ORDER BY ContactID


    SqlCommand cmd = new SqlCommand("dbo.GetPeopleByLastName"))
    {
    cmd.CommandType = CommandType.StoredProcedure;
    md.Parameters.Add(new SqlParameter("@LastName", "Alexander"));
    conn.Open();
    cmd.Connection = conn;

    using (SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
    {
    while (rdr.Read())
    {
    int contactID = rdr.GetInt32(rdr.GetOrdinal("ContactID"));
    string firstName = rdr.GetString(rdr.GetOrdina("FirstName"));
    Response.Write(firstName + " (" + contactID.ToString() + ")");
    }
    rdr.Close();
    }
    }

    dont forget to give rating


    Thanks & Regards!
    Syed Shakeer Hussain


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.