问题描述
- 将字符串转换为 uniqueidentifier 时失败
-
_lib.TSqlDB.ExecuteNonQuery(String Query) in C:WorkDocuments and SettingszaMy DocumentsVisual Studio ProjectsCMSCMS_libTSqlDB.cs:205
_lib.TData.Insert(String ExSql) in C:WorkDocuments and SettingszaMy DocumentsVisual Studio ProjectsCMSCMS_libTDataRset.cs:64
_lib.TCmsArticle.Insert() in C:WorkDocuments and SettingszaMy DocumentsVisual Studio ProjectsCMSCMS_libTCmsArticle.cs:82
_lib.CMS.Article.btnOK_ServerClick(Object sender, ImageClickEventArgs e) in C:WorkDocuments and SettingszaMy DocumentsVisual Studio ProjectsCMSCMSmanageArticle.aspx.cs:99
TSqlDB.cs:205
public static int ExecuteNonQuery(string Query)
{
int Result;SqlConnection myConnection = new SqlConnection(GetConnString()); myConnection.Open(); SqlCommand myCommand = new SqlCommand(Query, myConnection); Result= myCommand.ExecuteNonQuery(); myConnection.Close(); return Result; } TDataRset.cs:64 protected void Insert(string ExSql) { string strSql = GetInsertString(ExSql); TSqlDB.ExecuteNonQuery(strSql); } TCmsArticle.cs:82 public void Insert() { string ExSql = "newid(), '"+FArticleCID+"', null, getdate(), '"+FArticleTitle+"', '"+FArticleContent+"', '"+FArticleAuthor+"', 0, 1"; base.Insert(ExSql); } Article.aspx.cs:99 if (oArticle.ArticleContent.Length>4000) { oArticle.ArticleContent = oArticle.ArticleContent.Substring(0,4000); } oArticle.ArticleAuthor = txtArticleAuthor.Value; if (FIsNew) { oArticle.ArticleCID = FColumnID; oArticle.Insert(); } else { oArticle.Update(); }
解决方案
看看你的字符串是不是一个合法的GUID字符串,调试下。
解决方案二:
uniqueidentifier是数据库里的字段,对应C#里面的Guid
时间: 2024-10-20 18:28:06