Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6368141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:38:18+00:00 2026-05-25T00:38:18+00:00

I am having problem with the following code. Delete function does not work (throws

  • 0

I am having problem with the following code. Delete function does not work (throws scalar variable error). Update function does not work … it does not throw any error, but it simply does not make changes to the database.

If I make exact DetailsView, everything works OK. Where is the problem?

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ServisnaKnjiga.aspx.cs" Inherits="CernaticJurij_Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <p>
        Registrska številka:&nbsp;
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
&nbsp;&nbsp;
        <asp:Button ID="Button1" runat="server" Text="Iskanje" />
    </p>
    <p>
        <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
            AutoGenerateRows="False" CellPadding="4" DataSourceID="SqlDataSource1" 
            ForeColor="#333333" GridLines="None" Height="50px" Width="915px">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
            <EditRowStyle BackColor="#999999" />
            <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
            <Fields>
                <asp:BoundField DataField="REG_STEVILKA" HeaderText="REGISTRSKA ŠTEVILKA" 
                    SortExpression="REG_STEVILKA" InsertVisible="False" ReadOnly="True" />
                <asp:BoundField DataField="VIN_STEVILKA" HeaderText="VIN ŠTEVILKA" 
                    SortExpression="VIN_STEVILKA" InsertVisible="False" ReadOnly="True" />
                <asp:BoundField DataField="ZNAMKA" HeaderText="ZNAMKA" 
                    SortExpression="ZNAMKA" InsertVisible="False" ReadOnly="True" />
                <asp:BoundField DataField="MODEL" HeaderText="MODEL" SortExpression="MODEL" 
                    InsertVisible="False" ReadOnly="True" />
                <asp:BoundField DataField="LETO_IZDELAVE" HeaderText="LETO IZDELAVE" 
                    SortExpression="LETO_IZDELAVE" InsertVisible="False" ReadOnly="True" />
                <asp:BoundField DataField="ID_ZAPISA" HeaderText="ID_ZAPISA" 
                    InsertVisible="False" ReadOnly="True" SortExpression="ID_ZAPISA" />
                <asp:BoundField DataField="DATUM" HeaderText="DATUM" 
                    SortExpression="DATUM" />
                <asp:BoundField DataField="KILOMETRINA" HeaderText="KILOMETRINA" 
                    SortExpression="KILOMETRINA" />
                <asp:BoundField DataField="OPIS" HeaderText="OPIS" SortExpression="OPIS" />
                <asp:BoundField DataField="ODG_OSEBA" HeaderText="ODGOVORNA OSEBA" 
                    SortExpression="ODG_OSEBA" />
                <asp:BoundField DataField="CENA" HeaderText="CENA" SortExpression="CENA" />
                <asp:BoundField DataField="REG_STEVILKA1" HeaderText="REG_STEVILKA1" 
                    SortExpression="REG_STEVILKA1" Visible="False" />
                <asp:BoundField DataField="ID_STRANKE" HeaderText="ID_STRANKE" 
                    SortExpression="ID_STRANKE" Visible="False" />
                <asp:BoundField DataField="PROSTORNINA_MOTORJA" HeaderText="PROSTORNINA_MOTORJA" 
                    SortExpression="PROSTORNINA_MOTORJA" Visible="False" />
                <asp:BoundField DataField="MOC_MOTORJA" 
                    HeaderText="MOC_MOTORJA" SortExpression="MOC_MOTORJA" 
                    Visible="False" />
                <asp:BoundField DataField="TIP_MOTORJA" HeaderText="TIP_MOTORJA" 
                    SortExpression="TIP_MOTORJA" Visible="False" />
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                    ShowInsertButton="True" />
            </Fields>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        </asp:DetailsView>
    </p>
    <p>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Stranke %>" 
            DeleteCommand="DELETE FROM [SERVISNI_ZAPIS] WHERE [ID_ZAPISA] = @ID_ZAPISA"

            InsertCommand="INSERT INTO [SERVISNI_ZAPIS] ([REG_STEVILKA], [DATUM], [KILOMETRINA], [OPIS], [ODG_OSEBA], [CENA]) VALUES (@REG_STEVILKA, @DATUM, @KILOMETRINA, @OPIS, @ODG_OSEBA, @CENA)" SelectCommand="SELECT *
FROM SERVISNI_ZAPIS
FULL JOIN VOZILO
ON (SERVISNI_ZAPIS.REG_STEVILKA=VOZILO.REG_STEVILKA)
WHERE (SERVISNI_ZAPIS.REG_STEVILKA = @REG_STEVILKA)" 

            UpdateCommand="UPDATE [SERVISNI_ZAPIS] SET [REG_STEVILKA] = @REG_STEVILKA, [DATUM] = @DATUM, [KILOMETRINA] = @KILOMETRINA, [OPIS] = @OPIS, [ODG_OSEBA] = @ODG_OSEBA, [CENA] = @CENA WHERE [ID_ZAPISA] = @ID_ZAPISA">
            <DeleteParameters>
                <asp:Parameter Name="ID_ZAPISA" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="REG_STEVILKA" 
                    PropertyName="Text" />
                <asp:Parameter DbType="Date" Name="DATUM" />
                <asp:Parameter Name="KILOMETRINA" Type="String" />
                <asp:Parameter Name="OPIS" Type="String" />
                <asp:Parameter Name="ODG_OSEBA" Type="String" />
                <asp:Parameter Name="CENA" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="REG_STEVILKA" 
                    PropertyName="Text" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="REG_STEVILKA" Type="String" />
                <asp:Parameter DbType="Date" Name="DATUM" />
                <asp:Parameter Name="KILOMETRINA" Type="String" />
                <asp:Parameter Name="OPIS" Type="String" />
                <asp:Parameter Name="ODG_OSEBA" Type="String" />
                <asp:Parameter Name="CENA" Type="String" />
                <asp:Parameter Name="ID_ZAPISA" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </p>
    <p>
        &nbsp;</p>
    <p>
        &nbsp;</p>
</asp:Content>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:38:19+00:00Added an answer on May 25, 2026 at 12:38 am

    Do you mean it doesn’t work with a gridview but does work with a DetailsView? If so, then you need to set DataKeyNames for the gridview.

    You can look at this for further details: http://fabdata.wordpress.com/2007/03/23/must-declare-the-scalar-variable-id/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I'm having problem with initialization in java, following code give me compile error
I'm having problem in the following line: rd.PrintOptions.PaperSize = PaperSize.PaperFanfoldStdGerman; it throws an exception
I am having a problem using the repaint method in the following code.Please suggest
I'm having some problems with the following code: private class ClientPluginLoader : MarshalByRefObject {
I'm having the following problem. I created a application context file for spring.net. The
I'm having a little problem with the following: When I execute this line: echo
We're having problem with a huge number of legacy stored procedures at work. Do
Having a problem getting a TreeView control to display node images. The code below
Having a problem trying to create a function, as part of a BizTalk helper
We were having a problem with our build server not checking out modifications from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.