iT邦幫忙

0

變數名稱在一個查詢批次或預存程序內必須是唯一的

  • 分享至 

  • twitterImage

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

<%@ 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">                   請假單</strong></p>
<p class="style7">
 
<asp:Label ID="Labname" runat="server" style="font-size: medium" Text="申請人"></asp:Label>
 <asp:TextBox ID="Texname" runat="server"></asp:TextBox>
 
<asp:Label ID="Labvacation" runat="server" style="font-size: medium" Text="假別"></asp:Label>
 <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>
 <asp:Label ID="Labagent" runat="server" style="font-size: medium" Text="代理人"></asp:Label>
 <asp:TextBox ID="Texagent" runat="server"></asp:TextBox>
</p>
<p class="style7">
 
<asp:Label ID="Labstday" runat="server" style="font-size: medium" Text="起日期"></asp:Label>
 <asp:TextBox ID="Texstday" runat="server"></asp:TextBox>
 </p>

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

2
player
iT邦大師 1 級 ‧ 2012-08-20 19:27:47
最佳解答

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

cmkung iT邦新手 5 級 ‧ 2012-08-21 12:22:05 檢舉

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

2
外獅佬
iT邦大師 1 級 ‧ 2012-08-20 20:41:02

看起來應該是....重複宣告Parameter.....

看更多先前的回應...收起先前的回應...
外獅佬 iT邦大師 1 級 ‧ 2012-08-20 20:42:51 檢舉

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

外獅佬 iT邦大師 1 級 ‧ 2012-08-20 21:17:32 檢舉

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

&lt;pre class="c" name="code">
SqlDbCommand cmd = new SqlDbCommand("INSERT INTO table1 (field1) VALUES(@para)",conn);
foreach(var xxx in yyy)
{
  cmd.Parameters.AddWithValue("para",xxx.value);
  cmd.ExecuteNonQuery();
}
cmkung iT邦新手 5 級 ‧ 2012-08-21 09:19:05 檢舉

請問是那裏有錯
<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)">

cmkung iT邦新手 5 級 ‧ 2012-08-21 12:21:23 檢舉

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

我要發表回答

立即登入回答