数据删除问题uniqueidentifier数据类型
请给我大虾帮我看看是什么问题,如何解决,谢谢!本人刚开始学习数据库,基础不是很好。我在删除数据时没有反应。
1.我的数据表admin_news(ID,Name,Class)的字段的ID的数据类型为uniqueidentifier,其他的字段为varchar.
2.我定义了个数据操作类名称为Admin_News.cs,代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public interface IAdmin_News
{
/// <summary>
///
/// </summary>
/// <param name= "nID "> </param>
/// <returns> </returns>
int Dell_News(int nID);
}
/// <summary>
/// Admin_News 的摘要说明
/// </summary>
public class Admin_News:IAdmin_News
{
/// <summary>
///
/// </summary>
private static readonly string DELL_NEWS = "Delete admin_news Where ID= ";
public Admin_News()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public int Dell_News(int nID)
{
///创建链接
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings[ "Carera "].ConnectionString);
///定义SQL语句
string cmdText = DELL_NEWS
+ " ' " + nID.ToString() + " ' ";
///创建Command
SqlCommand myCommand = new SqlCommand(cmdText, myConnection);
///定义返回值
int nResult = -1;
try
{
///打开链接
myConnection.Open();
///执行SQL语句
nResult = myCommand.ExecuteNonQuery();
&