You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
939 B
C#

2 years ago
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;";
/// <summary>
/// 调用存储过程
/// </summary>
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();
}
}
}
}