會員中心 | iThome online | iT邦部落格 | 小7聚樂部 | iThome download | apphome

載入中...

cmkung

iT邦初學者
10級

變數名稱在一個查詢批次或預存程序內必須是唯一的
標籤:asp.net

我有查過網站上別人的同樣錯誤訊息 , 但程式不同所以無法引用在我的程式中

<%@ Page Title="" Language="VB" MasterPageFile="~/Main/MasterPage.master" AutoEventWireup="false" CodeFile="index.aspx.vb" Inherits="Main_index" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style7
{
font-size: xx-large;
font-family: 標楷體;
text-align: left;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>
</p>
<p class="style7">
<strong style="font-size: x-large">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 請假單</strong></p>
<p class="style7">
&nbsp;
<asp:Label ID="Labname" runat="server" style="font-size: medium" Text="申請人"></asp:Label>
&nbsp;<asp:TextBox ID="Texname" runat="server"></asp:TextBox>
&nbsp;
<asp:Label ID="Labvacation" runat="server" style="font-size: medium" Text="假別"></asp:Label>
&nbsp;<asp:DropDownList ID="Dropvacation" runat="server">
<asp:ListItem Selected="True">事假</asp:ListItem>
<asp:ListItem>公假</asp:ListItem>
<asp:ListItem>病假</asp:ListItem>
<asp:ListItem>婚假</asp:ListItem>
<asp:ListItem>喪假</asp:ListItem>
</asp:DropDownList>
&nbsp;<asp:Label ID="Labagent" runat="server" style="font-size: medium" Text="代理人"></asp:Label>
&nbsp;<asp:TextBox ID="Texagent" runat="server"></asp:TextBox>
</p>
<p class="style7">
&nbsp;
<asp:Label ID="Labstday" runat="server" style="font-size: medium" Text="起日期"></asp:Label>
&nbsp;<asp:TextBox ID="Texstday" runat="server"></asp:TextBox>
&nbsp;</p>

程式太長 , 要怎麼才放得下

2012-08-20 16:45:17 補充


發佈到:發佈到Facebook 發佈到噗浪 發佈到twitter
分享時間:2012-08-20 16:43:29
▼ ADVERTISEMENT ▼

最佳解答(發問者自選)
1

回答:player ( iT邦好手1級 )

時間:2012-08-20 19:27:47

如果你有用SqlDataSource 的話
請看它的 SelectCommand 是寫什麼?
如果它是用預存程序,請找該預存程序,撿查一下
如果不是的話,看是不是select時有寫錯? 

[-隱藏]

回應

1

cmkung 說:

cmkung提到:
原來是一個資料行對應兩個 textbox 才會錯亂

2012-08-21 12:22:05

變數名稱在一個查詢批次或預存程序內必須是唯一的
iT邦幫忙MVP
回答:wiselou( iT邦好手1級 )
時間:2012-08-20 20:41:02
1
看起來應該是....重複宣告Parameter.....
應該是SqlDbCommand2012-08-20 20:50:03 補充

[-隱藏]

回應 wiselou

1

wiselou 說:

在執行SqlCommand.Parameters.Add()添加參數之前
請先執行...SqlCommand.Parameters.Clear()

2012-08-20 20:42:51

2

wiselou 說:

這種錯誤,最常見的就是....

SqlDbCommand cmd = new SqlDbCommand("INSERT INTO table1 (field1) VALUES(@para)",conn);
foreach(var xxx in yyy)
{
  cmd.Parameters.AddWithValue("para",xxx.value);
  cmd.ExecuteNonQuery();
}

2012-08-20 21:17:32

3

cmkung 說:

請問是那裏有錯
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [vacation]"
InsertCommand="INSERT INTO vacation(name, vacarion, agent, startday, endday, totaltime, reason) VALUES (@name, @vacarion, @agent, @startday, @endday, @totaltime, @reason)">

2012-08-21 09:19:05

4

cmkung 說:

原來是一個資料行對應兩個 textbox 才會錯亂

2012-08-21 12:21:23

回應

請填寫您的回應,長度限為1,000個字,回應不計點數,也不限使用次數



 

檢舉違規

違規事項:

*補充檢舉理由(可省略),字數不可超過100字

推薦

推薦理由:


*給回答者的鼓勵(可不填),字數不可超過100字

哈哈
毆飛
開心
抗議
落寞
睡覺
噴鼻血
No
失神
爆氣
疑惑
Orz
不耐煩
喜歡
臉紅
噎到
放手
打嗑睡
掰掰
放馬過來
敲碗
簽名
筆記
拍手
沙發
XD
無言
偷笑
翻桌
謝謝
灑花
抱抱
逃跑
炸死你
愛你
生日快樂
rock
嘆氣
下雨
衝刺
搖頭
拍照
打球
健身
駭客
射門
泡湯
踹共
唱歌
做菜

上傳圖片
▼ ADVERTISEMENT ▼

邦友收藏動態

最新收藏最多人推最多人收

新增收藏

收藏到iT邦 書籤小工具

「收藏到iT邦」讓你更方便收藏站外文章。可用下面其中一種方法安裝:

  • 拖拉上面的「收藏到iT邦」連結到瀏覽器的書籤列
  • 在連結上方按右鍵,選擇「加到我的最愛」

之後看到喜歡的站外文章,只要點一下「收藏到iT邦」,就會收藏起來囉

安裝「收藏快捷鍵」

安裝「收藏快捷鍵」,可以讓邦友直接透過Google工具列上的按扭,快速收藏站內、站外的網頁。

訂閱每日摘要

iT邦幫忙即日起提供「每日摘要」給尚未註冊的邦友,只要輸入您的E-mail,每日就可以收到最新的發問與分享