I am having a horrible problem with some code, and I am just new enough to be completely frustrated. The code works perfect on my home computer, however when I download it to any of the servers I have access to, I get nothing but errors. The funny thing is, they are all windows servers, and I get different errors from each server using the same code.
Please click each of these links and see how the same code works on two different servers:
Now, let me list the code I am using:
Sub DummyRR(sender as Object, e as eventargs)
BindData()
End Sub
Sub BindData()
'1. Create a connection
Const strConnString as String = _
"Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=F:\IIS\ODUPC\foreign\Database\Missionaries.mdb"
Dim objConn as New OleDBConnection(strConnString)
'2. Create a command object for the query
Const strSQL as String = "SELECT Nbr, Day, Date, StartTime, ChurchName, City, PastorName FROM RRichardsonDates"
Dim objCmd as New OleDBCommand(strSQL, objConn)
objConn.Open() ' open the connection
'5. Specify the DataSource and Call DataBind()
dgComments.DataSource = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
dgComments.DataBind()
objConn.Close() ' close the connection
End Sub
Sub dgComments_EditRow(sender as object, e as DataGridCommandEventArgs)
dgComments.EditItemIndex = e.Item.ItemIndex
BindData()
End Sub
Sub dgComments_UpdateRow(sender as object, e as DataGridCommandEventArgs)
' Get information from columns ...
' Dim NbrTextBox as TextBox = e.Item.Cells(1).Controls(0)
Dim STTextBox as TextBox = e.Item.Cells(3).Controls(0)
Dim CNTextBox as TextBox = e.Item.Cells(4).Controls(0)
Dim CityTextBox as TextBox = e.Item.Cells(5).Controls(0)
Dim PNTextBox as TextBox = e.Item.Cells(6).Controls(0)
Dim iNbrID as Integer = dgComments.DataKeys(e.Item.Itemindex)
' Update the database ...
Dim strSQL as String
strSQL = "UPDATE RRichardsonDates SET StartTime = @Start, ChurchName = @Church, " & _
"City = @City, PastorName = @Pastor WHERE Nbr = @Nbr"
Const strConnString as String = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=F:\IIS\ODUPC\foreign\Database\Missionaries.mdb"
Dim objConn as New OleDBConnection(strConnString)
Dim objCmd As New OleDBCommand(strSQL, objConn)
Dim StartParam as New OleDbParameter("@Start", OleDBType.VarChar, 12)
Dim ChurchParam as New OleDbParameter("@Church", OleDbType.VarChar, 40)
Dim CityParam as New OleDbParameter("@City", OleDbType.VarChar, 30)
Dim PastorParam as New OleDbParameter("@Pastor", OleDbType.VarChar, 30)
Dim NbrParam As New OleDbParameter("@Nbr", OleDbType.Char, 1)
StartParam.Value = STTextBox.Text
objCmd.Parameters.Add(StartParam)
ChurchParam.Value = CNTextBox.Text
objCmd.Parameters.Add(ChurchParam)
CityParam.Value = CityTextBox.Text
objCmd.Parameters.Add(CityParam)
PastorParam.Value = PNTextBox.Text
objCmd.Parameters.Add(PastorParam)
NbrParam.Value = iNbrID
objCmd.Parameters.Add(NbrParam)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
dgComments.EditItemIndex = -1
BindData()
End Sub
Sub dgComments_CancelRow(sender as object, e as DataGridCommandEventArgs)
dgComments.EditItemIndex = -1
BindData()
End Sub
</script>
<!-- ************************* End of the SCRIPT Area ***************************************** -->
<body>
<!-- ********************Randy Richardson - Reunion, Mauritus, Seychelles ********************* -->
<Form runat="server">
<table width="75%" border="0" cellpadding="3">
<tr>
<td></td>
<td><b>Missionary Name</b></td>
<td><b>Field</b></td>
<td><b>Dates</b></td>
</tr>
<tr>
<td><asp:Button id="rrButton" Text="Schedule" onClick="DummyRR" runat="server" /></td>
<td>Rev. Randy Richardson</td>
<td>Reunion, Mauritus, Seychelles</td>
<td>Feb. 21 - Feb. 26, 2006</td>
</tr>
<tr colspan="4">
<aspataGrid id="dgComments" runat="server"
Font-Name="Verdana" Font-Size="9pt" CellPadding="5"
AlternatingItemStyle-BackColor="#dddddd"
AutoGenerateColumns="False"
DataKeyField="Nbr"
OnEditCommand="dgComments_EditRow"
OnUpdateCommand="dgComments_UpdateRow"
OnCancelCommand="dgComments_CancelRow" >
<HeaderStyle HorizontalAlign="Center" Font-Bold="True"
BackColor="Navy" ForeColor="White" Font-size="11pt"/>
<Columns>
<asp:EditCommandColumn ButtonType="PushButton" HeaderText="Edit"
EditText="Edit" UpdateText="Update" CancelText="Cancel" />
<asp:Boundcolumn Datafield="Day" HeaderText="Day" ReadOnly="true" />
<asp:Boundcolumn Datafield="Date" HeaderText="Date" ReadOnly="true"/>
<asp:Boundcolumn Datafield="StartTime" HeaderText="Start Time" />
<asp:Boundcolumn Datafield="ChurchName" HeaderText="Church Name" />
<asp:Boundcolumn Datafield="City" HeaderText="City" />
<asp:Boundcolumn Datafield="PastorName" HeaderText="Pastor"/>
</Columns>
</asp:datagrid>
</tr>
<!-- *********************************** End Randy Richardson ****************************** -->
</table>
</Form>
</body>
**** PLease, if anybody has any idea what is going on, I would appreciate any pointers in the right direction (as long as they aren't C++ pointers!)
Please click each of these links and see how the same code works on two different servers:
Now, let me list the code I am using:
Sub DummyRR(sender as Object, e as eventargs)
BindData()
End Sub
Sub BindData()
'1. Create a connection
Const strConnString as String = _
"Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=F:\IIS\ODUPC\foreign\Database\Missionaries.mdb"
Dim objConn as New OleDBConnection(strConnString)
'2. Create a command object for the query
Const strSQL as String = "SELECT Nbr, Day, Date, StartTime, ChurchName, City, PastorName FROM RRichardsonDates"
Dim objCmd as New OleDBCommand(strSQL, objConn)
objConn.Open() ' open the connection
'5. Specify the DataSource and Call DataBind()
dgComments.DataSource = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
dgComments.DataBind()
objConn.Close() ' close the connection
End Sub
Sub dgComments_EditRow(sender as object, e as DataGridCommandEventArgs)
dgComments.EditItemIndex = e.Item.ItemIndex
BindData()
End Sub
Sub dgComments_UpdateRow(sender as object, e as DataGridCommandEventArgs)
' Get information from columns ...
' Dim NbrTextBox as TextBox = e.Item.Cells(1).Controls(0)
Dim STTextBox as TextBox = e.Item.Cells(3).Controls(0)
Dim CNTextBox as TextBox = e.Item.Cells(4).Controls(0)
Dim CityTextBox as TextBox = e.Item.Cells(5).Controls(0)
Dim PNTextBox as TextBox = e.Item.Cells(6).Controls(0)
Dim iNbrID as Integer = dgComments.DataKeys(e.Item.Itemindex)
' Update the database ...
Dim strSQL as String
strSQL = "UPDATE RRichardsonDates SET StartTime = @Start, ChurchName = @Church, " & _
"City = @City, PastorName = @Pastor WHERE Nbr = @Nbr"
Const strConnString as String = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=F:\IIS\ODUPC\foreign\Database\Missionaries.mdb"
Dim objConn as New OleDBConnection(strConnString)
Dim objCmd As New OleDBCommand(strSQL, objConn)
Dim StartParam as New OleDbParameter("@Start", OleDBType.VarChar, 12)
Dim ChurchParam as New OleDbParameter("@Church", OleDbType.VarChar, 40)
Dim CityParam as New OleDbParameter("@City", OleDbType.VarChar, 30)
Dim PastorParam as New OleDbParameter("@Pastor", OleDbType.VarChar, 30)
Dim NbrParam As New OleDbParameter("@Nbr", OleDbType.Char, 1)
StartParam.Value = STTextBox.Text
objCmd.Parameters.Add(StartParam)
ChurchParam.Value = CNTextBox.Text
objCmd.Parameters.Add(ChurchParam)
CityParam.Value = CityTextBox.Text
objCmd.Parameters.Add(CityParam)
PastorParam.Value = PNTextBox.Text
objCmd.Parameters.Add(PastorParam)
NbrParam.Value = iNbrID
objCmd.Parameters.Add(NbrParam)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
dgComments.EditItemIndex = -1
BindData()
End Sub
Sub dgComments_CancelRow(sender as object, e as DataGridCommandEventArgs)
dgComments.EditItemIndex = -1
BindData()
End Sub
</script>
<!-- ************************* End of the SCRIPT Area ***************************************** -->
<body>
<!-- ********************Randy Richardson - Reunion, Mauritus, Seychelles ********************* -->
<Form runat="server">
<table width="75%" border="0" cellpadding="3">
<tr>
<td></td>
<td><b>Missionary Name</b></td>
<td><b>Field</b></td>
<td><b>Dates</b></td>
</tr>
<tr>
<td><asp:Button id="rrButton" Text="Schedule" onClick="DummyRR" runat="server" /></td>
<td>Rev. Randy Richardson</td>
<td>Reunion, Mauritus, Seychelles</td>
<td>Feb. 21 - Feb. 26, 2006</td>
</tr>
<tr colspan="4">
<aspataGrid id="dgComments" runat="server"
Font-Name="Verdana" Font-Size="9pt" CellPadding="5"
AlternatingItemStyle-BackColor="#dddddd"
AutoGenerateColumns="False"
DataKeyField="Nbr"
OnEditCommand="dgComments_EditRow"
OnUpdateCommand="dgComments_UpdateRow"
OnCancelCommand="dgComments_CancelRow" >
<HeaderStyle HorizontalAlign="Center" Font-Bold="True"
BackColor="Navy" ForeColor="White" Font-size="11pt"/>
<Columns>
<asp:EditCommandColumn ButtonType="PushButton" HeaderText="Edit"
EditText="Edit" UpdateText="Update" CancelText="Cancel" />
<asp:Boundcolumn Datafield="Day" HeaderText="Day" ReadOnly="true" />
<asp:Boundcolumn Datafield="Date" HeaderText="Date" ReadOnly="true"/>
<asp:Boundcolumn Datafield="StartTime" HeaderText="Start Time" />
<asp:Boundcolumn Datafield="ChurchName" HeaderText="Church Name" />
<asp:Boundcolumn Datafield="City" HeaderText="City" />
<asp:Boundcolumn Datafield="PastorName" HeaderText="Pastor"/>
</Columns>
</asp:datagrid>
</tr>
<!-- *********************************** End Randy Richardson ****************************** -->
</table>
</Form>
</body>
**** PLease, if anybody has any idea what is going on, I would appreciate any pointers in the right direction (as long as they aren't C++ pointers!)