以下是ASP.NET运行出现问题 ,请问该怎么处理?

using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;

/// <summary>
///BBSManager 的摘要说明
/// </summary>
public class BBSManager
{
public BBSManager()
{
}

/// <summary>
///添加论坛的类别
/// </summary>
/// <param name="name">类别名称</param>
/// <param name="des">类别描述信息</param>
///<returns>添加是否成功</returns>
public bool AddBBSCategory(string name, string des)

StringBuilder strSQL = new StringBuilder();

SqlParameter[] newsParms =new SqlParameter[] {

new SqlParameter("@name", SqlDbType.NVarChar,50),
new SqlParameter("@des", SqlDbType.NVarChar,100)};

SqlCommand cmd = new SqlCommand();
newsParms[0].Value = name;
newsParms[1].Value = des;
foreach (SqlParameter parm in newsParms)
cmd.Parameters.Add(parm);
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
strSQL.Append("Insert into BBSCategory values(@name, @des)");
conn.Open();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = strSQL.ToString();
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
if (val>0)
return true;
else
return false;
}
}
}

慕森卡
浏览 269回答 2
2回答

拉莫斯之舞

正规的语句:Insert into BBSCategory(字段,字段) values(@字段, @字段)而Insert into BBSCategory values(@字段, @字段) 表示表里只有两个字段(列)

ibeautiful

数据库的列多于你要插入的列,要写完整你要插入的列或插入特定列时,写清你要插入的列名在表明和values之间
打开App,查看更多内容
随时随地看视频慕课网APP