Invoking CLR stored procedures

前端 未结 5 1680
广开言路
广开言路 2021-01-16 15:08

In short, where can I find C#/VB client side sample code that calls CLR stored procedure with some argumnet [like a sqlxml data] and receives a datareader or other f

5条回答
  •  孤城傲影
    2021-01-16 15:22

    string connectionString = ConfigurationManager.AppSettings["ConnectDB"];
            SqlConnection sn = new SqlConnection(connectionString);
            SqlParameter[] sqlParameters = new SqlParameter[1];
            sn.Open();
            SqlCommand dCmd = new SqlCommand("dbo.HelloWorld", sn);
            dCmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader rdr = null;
            rdr = dCmd.ExecuteReader();
            while (rdr.Read())
                {
                for (int i = 0; i < rdr.FieldCount; i++)
                    Response.Write(rdr[i]);
                }
            sn.Close();
            }
    

提交回复
热议问题