using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ClrDemoTest { public class CallSQL { public static string SqlConnectionString = "server=.\\SQL2019;database=ClrDemo;uid=sa;pwd=gly-bicijinlian;"; /// /// 调用存储过程 /// public static void CallStoredProcedure() { using (SqlConnection connection = new SqlConnection(SqlConnectionString)) { connection.Open(); string sqlText = "Pro_ClrDemoNet35_GetRandom"; SqlCommand command = new SqlCommand(sqlText, connection); command.CommandType = CommandType.StoredProcedure; var result = command.ExecuteScalar(); connection.Close(); } } } }