参数化查询 '(@Name nvarchar(3)需要参数 '@TypeNum',但未提供该参数。
往sqlserver里面导入EXCEL数据
代码为:
public partial class formCustMgs : Form
{
public formCustMgs()
{
InitializeComponent();
}
private void btnImportFromExcel_Click(object sender, EventArgs e)
{
using (FileStream stream = File.OpenRead(@"c:\khzl.xls"))
{
HSSFWorkbook workbook = new HSSFWorkbook(stream);
HSSFSheet sheet = workbook.GetSheetAt(0);
for (int i = 1; i <= sheet.LastRowNum; i++)
{
T_customers cust = new T_customers();
HSSFRow row = sheet.GetRow(i);
HSSFCell cellName = row.GetCell(0);
cust.Name = cellName.StringCellValue;
HSSFCell telPhone = row.GetCell(1);
if (telPhone == null)
{
cust.TelPhone = "";
}
else if (telPhone.CellType == HSSFCell.CELL_TYPE_NUMERIC)
{
cust.TelPhone = row.GetCell(1).NumericCellValue.ToString();
}
&nbs