无法绑定由多个部分组成的标识符 “System.Web.UI.WebControls.TextBox“。

“/”应用程序中的服务器错误。
无法绑定由多个部分组成的标识符 “System.Web.UI.WebControls.TextBox”。
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Data.SqlClient.SqlException: 无法绑定由多个部分组成的标识符 “System.Web.UI.WebControls.TextBox”。

源错误:

行 43: SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
行 44: DataSet ds = new DataSet();
行 45: sda.Fill(ds);
行 46: conn.Close();
行 47: return ds;

源文件: E:\C#基础练习\试剂管理系统\DBHelper.cs 行: 45

堆栈跟踪:

[SqlException (0x80131904): 无法绑定由多个部分组成的标识符
“System.Web.UI.WebControls.TextBox”。]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection, Action1 wrapCloseInAction) +2581902 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
+6031382 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +297
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj, Boolean& dataReady) +4291
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +59
System.Data.SqlClient.SqlDataReader.get_MetaData() +91
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString, Boolean
isInternal, Boolean forDescribeParameterEncryption, Boolean
shouldCacheForAlwaysEncrypted) +446
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry,
SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2698
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, TaskCompletionSource`1 completion, Int32 timeout, Task& task,
Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +1540
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +65
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) +251
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) +43
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior) +12 System.Data.Common.DbDataAdapter.FillInternal(DataSet
dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords,
String srcTable, IDbCommand command, CommandBehavior behavior) +140
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +138
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +89
试剂管理系统.DBHelper.GetDataSet(String sql) in
E:\C#基础练习\试剂管理系统\DBHelper.cs:45 试剂管理系统.RuKu.Button1_Click(Object
sender, EventArgs e) in E:\C#基础练习\试剂管理系统\RuKu.aspx.cs:78
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9794234
System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument) +211
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1696

出现这种错误 ,主要问题是因给未给列明确指定所属的表读。如二个表同时有相同的子列,就到需要显示指定是哪个表。
示例如下,下面列中ID需要明确为a.ID 或b.ID
select ID,b.other from table a left ouer join table b on a.id=b.id – 出错,明确为A.ID即可。

你可能感兴趣的:(异常处理)