Click here to Skip to main content
16,020,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hiii all, i have write this code.

C#
GridViewRow row = GridView1.Rows[index];

              var text = GridView1.Rows[index].Cells[0].Text;

              string tb = ((TextBox)GridView1.Rows[index].FindControl("txt1")).Text;

              String[] sentences = Regex.Split(text, @"(?<=[.!?])\s+(?=\p{Lt})");

              System.Data.DataTable dt1 = new System.Data.DataTable();

              dt1.Columns.Add("SentenceText1");

              foreach (string value in sentences)
              {
                  if(!string.IsNullOrWhiteSpace(value))
                  dt1.Rows.Add(value);
              }
              SqlConnection con = new SqlConnection(conn);
              con.Open();
              string sql = "";
              for (int i = 0; i < dt1.Rows.Count; i++)
              {
                    var abc = dt1.Rows[i]["SentenceText1"].ToString();

--------------------- call storeprocedure ------------------------------------
now i want to use abc in store procedure to insert this data into table "sentence " so how can i write store procedure with input parameter abc.
Posted
Updated 4-Mar-15 21:13pm
v2

1 solution

Try:
SQL
CREATE PROC [dbo].Sample
@UserName varchar(100)
AS
BEGIN
SELECT Id FROM myTable WHERE UserName = @UserName
END

Then call it:
C#
int id = -1;
using (SqlCommand com = new SqlCommand("Sample", con))
    {
    com.CommandType = CommandType.StoredProcedure;
    com.Parameters.AddWithValue("@UserName", abc);
    using (SqlDataReader read = com.ExecuteReader())
       {
       if (read.Read()) id = (int) read["Id"];
       }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900