הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   בעיה בפקד SqlDataSourceו (https://hosts.co.il/forums/showthread.php?t=20816)

alex 28-04-06 16:25

בעיה בפקד SqlDataSourceו
 
שלום

יש לי משימה, להוסיף למסד נתונים של MSSQL רשומה בעזרת הפקד SqlDataSource.

אני יוצר את הפקד [הנה הקוד המתקבל]



קוד:

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        InsertCommand="INSERT INTO customers(customerID) VALUES (newparameter)" SelectCommand="SELECT [customerID] FROM [customers]">
                     

<InsertParameters>
                            <asp:ControlParameter ControlID="customerIDtxt" Name="newparameter" PropertyName="Text" />
                        </InsertParameters>
                    </asp:SqlDataSource>


כאשר יש פרמטר שאמור להכנס לVALUES, שעורכו של הפרטמטר הוא בעצם תיבת הטקסט.
אולם כשאני מריץ את הקוד מופיע השגיאה:




קוד:

The name "newparameter" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.


כשאני מנסה ישר לכתוב את תיבת הטקסט, כלומר:


קוד:

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        InsertCommand="INSERT INTO customers(customerID) VALUES (customerIDtxt.text)" SelectCommand="SELECT [customerID] FROM [customers]">



מופיע אותה שגיאה, בהחלפת המילהnewparameter בTEXTBOX.

זהוי הפקודה בעת לחיצה על לחצן:



קוד:

Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs)
        SqlDataSource2.Insert()
    End Sub



כל הזמנים הם GMT +2. הזמן כעת הוא 22:05.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ