Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Totally Frustrated with ASP.Net

Status
Not open for further replies.

smmurph

IS-IT--Management
Jul 8, 2005
10
US
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">

<asp:DataGrid 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!) :)
 
Try this:

objCmd.Parameters.Add(StartParam)
StartParam.Value = STTextBox.Text

objCmd.Parameters.Add(ChurchParam)
ChurchParam.Value = CNTextBox.Text

objCmd.Parameters.Add(CityParam)
CityParam.Value = CityTextBox.Text

objCmd.Parameters.Add(PastorParam)
PastorParam.Value = PNTextBox.Text

objCmd.Parameters.Add(NbrParam)
NbrParam.Value = iNbrID


I think the problem may be that you are trying to assign values to parameters before the parameters are actually added to the parameters collection.

Just a guess...
 
Does the ASP.NET\Machine_Name account have write permissions on this folder? F:\IIS\ODUPC\foreign\Database\


Vince
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top