Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 17th, 2004, 11:48 AM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default error in inserting the data in database

Hi..
I am getting data in dropdownlist from the database.
after updating that field I am trying to update the field assingn to that field ..

I am trying to update the table. but it is giveing me error!!!
I am trying to update the table to multipal rows. in a table.
If any body have the idea why I am getting the error please help me out.
thanks
My condition like

Aashish Shah
__________________
Aashish Shah
 
Old February 17th, 2004, 12:17 PM
Registered User
 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mate,

What error are you getting from the database?

What database are you running against?

Does your query run succesfully against the database if you submit it via sqlplus (or whatever the equivalent tool is?).

What code are you running?

Cheers,

Ewan

 
Old February 17th, 2004, 12:38 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Function GetLastUpdated(strTableName)
                       Dim strSQL1 As String
                       Dim strUpdated as string


                              strSQL1 = "select to_char((max(ATTEND_DATE)),'mm/dd/yyyy')dt from ALT_ED_ATTENDANCE"

                                  Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;;Data Source=;Persist Security Info=true")
                                  Dim myCommand As OleDbCommand = New OleDbCommand(strSQL1, myConnection)


                                  Try
                                      myConnection.Open()
                                      Dim result As OleDbDataReader = myCommand.ExecuteReader()

                                      result.Read()
                                      strUpdated = result("dt")

                                        result.Close()


                                  Catch err as Exception
                                      strUpdated="Error getting date."
                                  Finally

                                  If (Not myConnection is Nothing) Then
                                       myConnection.Close()
                                  End If

                                  end try


                      return strUpdated


                  End Function

         Function GetDataSource()
                      Dim dt As New DataTable()
                      Dim dr As DataRow
                      Dim defult as String

                       Dim strSQL2 as String

                     If Not IsPostBack Then




                              strSQL2 = "select descr Reason, absence_cd code from absence_cd"


                     end if
                      Dim myConnection2 As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;Password=hs;Pe rsist Security Info=true")
                      Dim myCommand As OleDbCommand = New OleDbCommand(strSQL2, myConnection2)

                        myConnection2.Open ()

                        Dim result As OleDbDataReader = myCommand.ExecuteReader

                        dt.Columns.Add(New DataColumn("Code", GetType(String)))
                        dt.Columns.Add(New DataColumn("Reason", GetType(String)))




                        Do While result.Read()

                                  dr = dt.NewRow()

                                  dr(0) = result("code")
                                  dr(1) = result("Reason")
                                   dt.Rows.Add(dr)
                         Loop

                         result.Close()

                         myConnection2.Close ()

                          Dim dv As New DataView(dt)
                          Return dv

              End Function

              Protected strCourseCode As String


              Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)


                     Dim strLastUpdated As String

                    Dim strSQL As String


                    strSQL= "select a.attend_date, a.permnum,a.lastname || ', ' || firstname student_name, 'Taft High School ' alternate_schoolnum, a.sending_schoolnum,asch.name scn from asch,alt_ed_attendance a ,(select to_char((max(ATTEND_DATE)),'mm/dd/yyyy') max_dt from alt_ed_attendance) b where asch.schoolnum = a.sending_schoolnum and a.alternate_schoolnum=410 and to_char((a.ATTEND_DATE),'mm/dd/yyyy')= max_dt"




                 Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;;Persist Security Info=true")

                  Dim myCommand2 As OleDbCommand = New OleDbCommand(strSQL, myConnection)
                              Try
                                  myConnection.Open()
                                  Dim result As OleDbDataReader = myCommand2.ExecuteReader()

                                  MyList.DataSource = result
                                  MyList.DataBind()


                                  MyList.Columns(1).ItemStyle.HorizontalAlign=Horizo ntalAlign.left
                                     MyList.Columns(2).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center
                                     MyList.Columns(3).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center
                                     MyList.Columns(4).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center

                                  result.Close()

                             Catch err as Exception


                                  end try

                             strLastUpdated = GetLastUpdated("LOAD alt_ed_attendance")

                                  lblUpdated.Text = "DATE: " & strLastUpdated



                              If (Not myConnection is Nothing) Then

                                   myConnection.Close()

                              End If



           Dim myConnection3 As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;;Persist Security Info=true")
                                  Dim myCommand As OleDbCommand = New OleDbCommand(strSQL, myConnection3)


                                  myConnection3.Open ()





              end Sub


              Sub reason_SelectedIndexChanged(sender As Object, e As EventArgs)

               Dim strSQLreason As String


                    strSQLreason= "select absence_cd,descr,type from from absence_cd"




                 Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;;Persist Security Info=true")

                  Dim myCommand2 As OleDbCommand = New OleDbCommand(strSQLreason, myConnection)
                              Try
                                  myConnection.Open()

                              catch

                              end try
              End Sub
              '

         Sub DataGrid1_SelectedIndexChanged(sender As Object, e As EventArgs)

         End Sub
    '<asp:DropDownList id="txtReason" runat="server" width="150"></asp:DropDownList>

</script>

<html>
<head>
</head>
<body bottommargin="0" bgcolor="#fffff8" leftmargin="0" topmargin="0" scroll="yes" rightmargin="0" marginheight="0" marginwidth="0">
    <p align="center">
        <img height="77" src="cps.gif" width="420" align="center" />
    </p>
    <p>
        <br />
        <b>Alternate Education Location: </b>
    </p>
    <b>
    <p>
        <asp:Label class="Normal" id="lblUpdated" visible="true" align="right" runat="Server">Label</asp:Label>
    </p>
    <p>
    </p>
    </b>
    <table height="100%" cellspacing="0" cellpadding="0" width="800" align="center">
        <tbody>
            <form runat="server">
                <tr valign="top">
                    <td width="1500">

                        <asp:DataGrid id="MyList" runat="server" Font-Names="Verdana" GridLines="BOTH" AutoGenerateColumns="false" AlternatingItemStyle-CssClass="CartListItemAlt" ItemStyle-CssClass="CartListItem" FooterStyle-CssClass="cartlistfooter" HeaderStyle-CssClass="CartListHead" Font-Size="8pt" Font-Name="Verdana" cellspacing="0" cellpadding="4" BorderColor="black" width="100%" HorizontalAlign="Center">
                            <FooterStyle cssclass="cartlistfooter"></FooterStyle>
                            <HeaderStyle font-bold="True" cssclass="CartListHead" backcolor="#80FFFF" horizontalalign="Center"></HeaderStyle>
                            <AlternatingItemStyle cssclass="CartListItemAlt"></AlternatingItemStyle>
                            <ItemStyle font-bold="False" cssclass="CartListItem"></ItemStyle>
                            <Columns>
                                <asp:BoundColumn Visible="False" DataField="attend_date" HeaderText="Date"></asp:BoundColumn>
                                <asp:BoundColumn DataField="permnum" HeaderText="StudentID"></asp:BoundColumn>
                                <asp:BoundColumn DataField="student_name" HeaderText="Student Name"></asp:BoundColumn>
                                <asp:BoundColumn DataField="scn" HeaderText="Current School"></asp:BoundColumn>
                                <asp:TemplateColumn Headertext="Reason">
                                    <itemTemplate>
                                        <asp:DropDownList id="txtReason" runat="server" width="150" dataTextField="Reason" DataValueField="code" datasource='<%#GetDataSource()%>' ></asp:DropDownList>
                                    </itemTemplate>
                                </asp:TemplateColumn>
                            </Columns>
                        </asp:DataGrid>
                        <div align="center">
                        </div>
                        <div align="center">
                        </div>
                        <div class="Submit" id="butUpdate" title="Save" align="center">
                            <asp:Button id="Button1" runat="server" BorderColor="#00C000" BackColor="#004000" ForeColor="White" Text="Save"></asp:Button>
                        </div>
                        </td>
                </tr>
            </form>
        </tbody>
</table>
this is the compleate code .
can you tell me how to get the value of the dropdownlist.
b'cos database is getting the value that field everytime "null"
and gives me error like nodata found for that column.
thanks aashish

Aashish Shah
 
Old February 17th, 2004, 01:33 PM
Registered User
 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Does the SQL all work if you execute it directly against the database?

 
Old February 17th, 2004, 02:15 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it is working.. but what happen I am not able to get the data value from the dropdownlist.

to update that value in the database..

thansk
aashish

Aashish Shah





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with inserting data into access database ITladybug ADO.NET 1 January 1st, 2006 01:50 PM
Inserting data into Access database OldCoder ASP.NET 2.0 Basics 1 December 31st, 2005 06:26 PM
inserting blob data into database taoufik Beginning PHP 2 November 19th, 2004 09:28 AM
inserting data into Sql Database CodeMonkeys C# 6 August 31st, 2004 04:21 PM
failure in inserting data into database ckmun81 Access ASP 3 December 21st, 2003 08:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.