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
|