gns1497's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
New Members
Active Posts:
11 (0.02 per day)
Joined:
27-June 12
Profile Views:
302
Last Active:
User is offline Nov 13 2013 03:35 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   gns1497 has not set their status

Posts I've Made

  1. In Topic: Having problem reading from sql server view

    Posted 9 Oct 2013

    View Postandrewsw, on 07 October 2013 - 12:32 PM, said:

    The error message should give you some indication of where the error is. I don't use ASP.NET but assume you can press Break, or similar, and it will take you to the error.

    The error message itself suggests that you have a missing, or extra, bracket, or some similar simple syntax error which shouldn't be too difficult to spot.

    BTW What's all this..

             
                       &
    

    Eek! :dontgetit:/> Use css if you want to separate elements.



    The   was auto written using the .net suite. I didnt write that code. This is just page spacing however, and is not of concern. I really dont care about that. My concern is getting the query to work and displaying the datagrid. I can tweak html later if necessary.

    I'm afraid this is more complicated than an extra bracket. This very same query works fine when I run it in SQL Server Management Studio directly against the database. For whatever reason, it doesnt like the line below.

    sqlRead = sqlCmd.ExecuteReader()
  2. In Topic: Having problem reading from sql server view

    Posted 7 Oct 2013

    View Postybadragon, on 07 October 2013 - 09:31 AM, said:

    What is the error you get?


    SqlException was unhandled by user code (title bar of error in debug mode vs.net. "Incorrect syntax near ')'."
  3. In Topic: Unable to update or delete records from SQL 2008 database

    Posted 16 Aug 2012

    View PostNakor, on 19 July 2012 - 04:33 PM, said:

    SELECT [fldAppName] as 'Application', [fldGroupName] as 'Group Name', [fldAppSymID] as 'Symposium ID', 
           [fldAppPhone] as 'Phone', [fldAppPhoneOpt] as 'Options' 
    FROM [tblApplication] 
    WHERE ([fldGroupName] = @fldGroupName) ORDER BY [fldAppName]
    
    


    You're giving an alias to your columns. The boundfields will be looking for the alias name not the real column name. You would need to bind to "Application" instead of "fldAppName". Either that or remove the aliases.




    Thanks for all the help, Nakor. I found that once I changed this to use the Alias it worked, but took me back to the original error that I mentioned in the first post of this thread. After much use of Google :) I found this was being caused by the spaces in my alias'. Once I replaced the spaces with underscores...voila. I actually ended up removing all of the alias' and manually defining my columns in the gridview and setting the "HeaderText" property with what I wanted them to display as. The worked perfectly. Thanks again for your help.
  4. In Topic: Unable to update or delete records from SQL 2008 database

    Posted 19 Jul 2012

    Okay, I was able to find what what I was missing on my vb code, but now I'm getting a different error when I run the page and I believe I'm missing something on the ASP.net side.

    The error I'm getting now is:



    Server Error in '/DISCuSS' Application.
    --------------------------------------------------------------------------------

    DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'fldAppName'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'fldAppName'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [HttpException (0x80004005): DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'fldAppName'.]
    System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +8681317
    System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +2178
    System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
    System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +14
    System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
    System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
    System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
    System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
    System.Web.UI.WebControls.GridView.DataBind() +4
    System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
    System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +72
    System.Web.UI.Control.EnsureChildControls() +87
    System.Web.UI.Control.PreRenderRecursiveInternal() +44
    System.Web.UI.Control.PreRenderRecursiveInternal() +171
    System.Web.UI.Control.PreRenderRecursiveInternal() +171
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

    --------------------------------------------------------------------------------------------------------------------------------







    Here's my ASP code (note the Gridview tag, as I think this is where the page bombs)




    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>DISCuSS.Net</title>
        <style type="text/css">
            #form1
            {
                height: 743px;
                width: 858px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        <asp:SqlDataSource ID="dsApp" runat="server" 
            SelectCommand="SELECT [fldAppName] as 'Application', [fldGroupName] as 'Group Name', [fldAppSymID] as 'Symposium ID', 
                           [fldAppPhone] as 'Phone', [fldAppPhoneOpt] as 'Options' FROM [tblApplication] 
                           WHERE ([fldGroupName] = @fldGroupName) ORDER BY [fldAppName]" 
            ConnectionString="<%$ ConnectionStrings:DiscussSQLConnectionString %>" 
            DeleteCommand="DELETE FROM [tblApplication] WHERE [fldAppName] = @original_fldAppName AND 
                          (([fldGroupName] = @original_fldGroupName) OR ([fldGroupName] IS NULL AND @original_fldGroupName IS NULL)) AND 
                          (([fldAppSymID] = @original_fldAppSymID) OR ([fldAppSymID] IS NULL AND @original_fldAppSymID IS NULL)) AND 
                          (([fldAppPhone] = @original_fldAppPhone) OR ([fldAppPhone] IS NULL AND @original_fldAppPhone IS NULL)) AND 
                          (([fldAppPhoneOpt] = @original_fldAppPhoneOpt) OR ([fldAppPhoneOpt] IS NULL AND @original_fldAppPhoneOpt IS NULL))" 
            InsertCommand="INSERT INTO [tblApplication] ([fldAppName], [fldGroupName], [fldAppSymID], [fldAppPhone], [fldAppPhoneOpt]) 
                          VALUES (@fldAppName, @fldGroupName, @fldAppSymID, @fldAppPhone, @fldAppPhoneOpt)" 
                          
            OldValuesParameterFormatString="original_{0}" 
            
            UpdateCommand="UPDATE [tblApplication] SET [fldGroupName] = @fldGroupName, [fldAppSymID] = @fldAppSymID, 
                          [fldAppPhone] = @fldAppPhone, [fldAppPhoneOpt] = @fldAppPhoneOpt
                          WHERE [fldAppName] = @original_fldAppName AND (([fldGroupName] = @original_fldGroupName) OR 
                          ([fldGroupName] IS NULL AND @original_fldGroupName IS NULL)) AND (([fldAppSymID] = @original_fldAppSymID) OR 
                          ([fldAppSymID] IS NULL AND @original_fldAppSymID IS NULL)) AND (([fldAppPhone] = @original_fldAppPhone) OR 
                          ([fldAppPhone] IS NULL AND @original_fldAppPhone IS NULL)) AND (([fldAppPhoneOpt] = @original_fldAppPhoneOpt) OR 
                          ([fldAppPhoneOpt] IS NULL AND @original_fldAppPhoneOpt IS NULL))">
                          
            <SelectParameters>
                <asp:ControlParameter ControlID="cboGroup" Name="fldGroupName" 
                    PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
            
            <DeleteParameters>
                <asp:Parameter Name="original_fldAppName" Type="String" />
                <asp:Parameter Name="original_fldGroupName" Type="String" />
                <asp:Parameter Name="original_fldAppSymID" Type="String" />
                <asp:Parameter Name="original_fldAppPhone" Type="String" />
                <asp:Parameter Name="original_fldAppPhoneOpt" Type="String" />
            </DeleteParameters>
            
            <UpdateParameters>
                <asp:Parameter Name="fldAppName" Type="String" />
                <asp:Parameter Name="fldGroupName" Type="String" />
                <asp:Parameter Name="fldAppSymID" Type="String" />
                <asp:Parameter Name="fldAppPhone" Type="String" />
                <asp:Parameter Name="fldAppPhoneOpt" Type="String" />
                <asp:Parameter Name="original_fldAppName" Type="String" />
                <asp:Parameter Name="original_fldGroupName" Type="String" />
                <asp:Parameter Name="original_fldAppSymID" Type="String" />
                <asp:Parameter Name="original_fldAppPhone" Type="String" />
                <asp:Parameter Name="original_fldAppPhoneOpt" Type="String" />
            </UpdateParameters>
            
            <InsertParameters>
                <asp:Parameter Name="fldAppName" Type="String" />
                <asp:Parameter Name="fldGroupName" Type="String" />
                <asp:Parameter Name="fldAppSymID" Type="String" />
                <asp:Parameter Name="fldAppPhone" Type="String" />
                <asp:Parameter Name="fldAppPhoneOpt" Type="String" />
                <asp:Parameter Name="original_fldAppName" Type="String" />
                <asp:Parameter Name="original_fldGroupName" Type="String" />
                <asp:Parameter Name="original_fldAppSymID" Type="String" />
                <asp:Parameter Name="original_fldAppPhone" Type="String" />
                <asp:Parameter Name="original_fldAppPhoneOpt" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
          
    
        
            <asp:SqlDataSource ID="dsGroupName" runat="server" 
            ConnectionString="<%$ ConnectionStrings:DiscussSQLConnectionString %>" 
            
            SelectCommand="SELECT [fldGroupName] FROM [tblGroup] ORDER BY [fldGroupName]"></asp:SqlDataSource>
          
    
        
            <br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Image ID="Image1" runat="server" Height="87px" 
            ImageUrl="~/images/HCA.jpg" Width="224px" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Image ID="imgDISCuSS" runat="server" Height="42px" 
            ImageUrl="~/images/DISCuSS.jpg" style="margin-top: 3px" Width="131px" />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <br />
        <br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="cmdInformation" runat="server" Text="Information" 
            Width="107px" Font-Size="X-Small" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:DropDownList ID="cboGroup" runat="server" DataSourceID="dsGroupName" DataTextField="fldGroupName" DataValueField="fldGroupName" AppendDataBoundItems="true" onselectedIndexChanged="cboGroup_SelectedIndexChanged" AutoPostBack="True"
            Height="18px" Width="309px">
        </asp:DropDownList>
        
        <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="cmdDictionaries" runat="server" Text="Dictionaries" 
                Width="107px" Font-Size="X-Small" />
        <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="cmdManual" runat="server" Text="User Manual" 
                Width="107px" Font-Size="X-Small" />
        <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="cmdMain" runat="server" Text="Main Menu" 
                Width="107px" Font-Size="X-Small" />
                
                
         &nbsp;&nbsp;&nbsp;
        <br />
        <br />
       <div style="margin-left: 280px">
                  
            <asp:GridView ID="gvGroupApps" runat="server" ShowFooter="True" AllowPaging="True" CellPadding="4" DataSourceID="dsApp"
                ForeColor="#333333" GridLines="None" OnRowUpdating="GvGroupApps_Update" datakeynames="fldAppName">
                <RowStyle BackColor="#E3EAEB" />
                <Columns>
                    <asp:CommandField ShowInsertButton="True" ShowDeleteButton="True" ShowEditButton="True"/>
                </Columns>
                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#7C6F57" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>
        </div>   
        
        
        </form>
        </body>
    </html>
    
    




    Here's my vb code from the codebehind page:
    
    Imports System
    Imports System.Data
    Imports System.Data.Sql
    Imports System.Data.SqlClient
    Imports System.Data.DataRowView
    
    
    Partial Class ApplicationSearch
        Inherits System.Web.UI.Page
    
        Protected Sub cmdInformation_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdInformation.Click
            Response.Redirect(String.Format("~/Information.aspx?"))
        End Sub
    
        Protected Sub cmdDictionaries_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdDictionaries.Click
            Response.Redirect(String.Format("~/Dictionaries.aspx?"))
        End Sub
        Protected Sub cmdManual_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdManual.Click
            Response.Redirect(String.Format("~/Manual.aspx?"))
        End Sub
    
        Protected Sub cmdMain_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdMain.Click
            Response.Redirect(String.Format("~/Default.aspx?"))
        End Sub
    
        Protected Sub cboGroup_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboGroup.SelectedIndexChanged
            Dim cboGroup As String = TryCast(sender, DropDownList).SelectedValue
            Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("DiscussSQLConnectionString").ConnectionString)
            Dim sSql As System.Xml.Linq.XElement = <sql>
    
                SELECT [fldAppName], [fldGroupName], [fldAppSymID], [fldAppPhone], [fldAppPhoneOpt] 
                FROM [tblApplication]
    
                WHERE ([fldGroupName] = '<%= cboGroup %>') 
                ORDER BY [fldAppName] </sql>
    
            Dim sqlCmd As New SqlCommand(sSql.Value, sqlConn)
            Dim sqlRead As SqlDataReader
            If sqlConn.State <> ConnectionState.Open Then
                sqlConn.Open()
            End If
            sqlRead = sqlCmd.ExecuteReader()
            sqlRead.Read()
    
            sqlRead.Close()
            sqlConn.Close()
        End Sub
    
        Function SendSQLCommand(ByVal tsSQLCmd As String, ByVal tsqlConn As SqlConnection) As Integer
            Dim iRetVal As Integer = -1
            Dim sqlCmd As New SqlCommand(tsSQLCmd, tsqlConn)
            If tsqlConn.State <> ConnectionState.Open Then
                tsqlConn.Open()
            End If
            Try
                iRetVal = sqlCmd.ExecuteNonQuery()
            Catch ex As Exception
                Throw ex
            End Try
            Return iRetVal
        End Function
    
        Protected Sub GvGroupApps_Update(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs)
            Dim keyValue As String = e.Keys("cAppPK").ToString()
            Dim cAppName As String = Session("fldAppName")
            Dim cGroupName As String = Session("fldGroupName")
            Dim cAppSymID As String = Session("fldAppSymID")
            Dim cAppPhone As String = Session("fldAppPhone")
            Dim cAppPhoneOpt As String = Session("fldAppPhoneOpt")
    
            Dim strfldAppNameOld As String = RTrim(LTrim(e.OldValues("cappname").ToString()))
            Dim strfldAppNameNew As String = RTrim(LTrim(e.NewValues("cappname").ToString()))
    
            Dim strfldGroupNameOld As String = RTrim(LTrim(e.OldValues("cgroupname").ToString()))
            Dim strfldGroupNameNew As String = RTrim(LTrim(e.NewValues("cgroupname").ToString()))
    
            Dim strfldAppSymIDOld As String = RTrim(LTrim(e.OldValues("cappsymid").ToString()))
            Dim strfldAppSymIDNew As String = RTrim(LTrim(e.NewValues("cappsymid").ToString()))
    
            Dim strfldAppPhoneOld As String = RTrim(LTrim(e.OldValues("cappohone").ToString()))
            Dim strfldAppPhoneNew As String = RTrim(LTrim(e.NewValues("capphone").ToString()))
    
            Dim strfldAppPhoneOptOld As String = RTrim(LTrim(e.OldValues("cAppPhoneOpt").ToString()))
            Dim strfldAppPhoneOptNew As String = RTrim(LTrim(e.NewValues("cappphoneopt").ToString()))
    
            gvGroupApps_Updated(keyValue, strfldAppNameNew, strfldGroupNameNew, strfldAppSymIDNew, strfldAppPhoneNew, strfldAppPhoneOptNew)
    
            'http://support.microsoft.com/kb/301248
    
        End Sub
    
        Protected Sub gvGroupApps_Updated(ByVal cAppPK As String, ByVal fldAppName As String, ByVal fldGroupName As String, ByVal fldAppSymID As String, ByVal fldAppPhone As String, ByVal fldAppPhoneOpt As String)
            Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("DiscussSQLConnectionString").ConnectionString)
            Dim sSql As XElement
            sSql = <sql>
                Update [tblApplication] SET [cAppName] = '<%= [fldAppName] %>' 
                       ,[cGroupName] = "<%= [fldGroupName] %>', [cAppSymID] = <%= [fldAppSymID] %>' 
                       ,[cAppPhone] = <%= [fldAppPhone] %>', [cAppPhoneOpt] = <%= [fldAppPhoneOpt] %>'
                Where [cAppPK] = '<%= [fldAppName] %>' </sql>
    
            'MsgBox(Err.Description, MsgBoxStyle.Critical, "SQL Error")
    
            SendSQLCommand(sSql.Value, sqlConn)
            sqlConn.Close()
        End Sub
    End Class
    
    



    Can anyone tell me what I'm missing? Any help is much appreciated!
  5. In Topic: Unable to update or delete records from SQL 2008 database

    Posted 5 Jul 2012

    View PostNakor, on 29 June 2012 - 04:09 PM, said:

    In order to maintain concurrency it is attempting to validate that none of the existing values have been modified before updating with the values you've entered. I'm not sure why, but this usually gives me problems as well. Try simplifying the where statement and see if it allows you to perform an update.



    Thanks for your reply. I had already tried this, however get the same result. I even took the where statement out completely and get the same error. I think I was missing the code on the code behind page (VB.net). I added a reference to a sub in my code behind page. I've added the code to execute the update on the VB side in the code behind page. Here's the code.

    ASP
    <asp:GridView ID="gvGroupApps" runat="server" ShowFooter="True" AllowPaging="True" CellPadding="4" DataSourceID="dsApp"
                ForeColor="#333333" GridLines="None" OnRowUpdating="GvGroupApps_Update">
                <RowStyle BackColor="#E3EAEB" />
                <Columns>
                    <asp:CommandField ShowInsertButton="True" ShowDeleteButton="True" ShowEditButton="True"/>
                </Columns>
                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#7C6F57" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>
    
    



    Here's the vb code for the "GvGroupApps_Update" reference in the gridview tag.

    
    Protected Sub GvGroupApps_Update(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs)
            dsApp.Update()
            dsApp.DataBind()
    End Sub
    
    
    



    dsApp is my sql datasource. Am I on the right track here?

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

gns1497 hasn't added any friends yet.

Comments

gns1497 has no profile comments yet. Why not say hello?