Friday, February 24, 2012

Developer Environment vs. Live Server

I am experiencing a situation where certain functions work perfectly when I run it on my local machine under MVS, but when I upload it to the server, then it does not?!

Here is an example:

I am using a drop down box (in a FormView) that is databound in an online submission form. When I run the application in MVS, then I can edit the records by opening the form, and selection the new value in the drop down list. The new value is then also saved to the database when I hit the update button. When I upload the code to the server, then the drop down list shows the correct information (so the databinding to the control seem to work correctly), but the new value is not saved to the database.

Here is the code for the drop down list:

"DropDownList1" runat="server" DataSourceID="SqlDataSource3"
DataTextField="UserName" DataValueField="UserId" SelectedValue='<%# Bind("UserId") %>'
CssClass="text">
"SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:LocalSqlServer %>"
SelectCommand="SELECT [UserName], [UserId] FROM [vw_aspnet_Users] ORDER BY [UserName]">


Here is the code updating the database with the record (I have removed some records as well as the Insert and Delete parts):

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:tourism_connect1 %>"
UpdateCommand="UPDATE Resorts SET typeid = @.typeid, destrictid = @.destrictid, UserId = @.UserId, WHERE (resortid = @.resortid)"
OnInserted="SqlDataSource1_Inserted">

<UpdateParameters>
<asp:Parameter Name="typeid" />
<asp:Parameter Name="destrictid" />
<asp:Parameter Name="UserId" />
<asp:Parameter Name="resortid" />
</UpdateParameters>
</asp:SqlDataSource>

What I can mention further, is that if I connect to the database that is on the live server (so the application runs in MVS on my local machine, but it then retrieves the info from the online database), then it also works fine. It is just giving this issue when the online application is trying to update the values.

There is also no errors during the process.

I will appreciate any advise on how to overcome this, as I really do not know where to look anymore...

Thanks in advance!

Regards

Jan

Have you checked logs? My first guess is a permission error, but it's a guess at this point with the given information.

Jeff

|||

Hi Jeff,

I had a look at all possible permission settings, and I just could not find anything! Unfortunately my service provider can not give me access to the logs at this time, so since everything else failed, I decided to redo the whole lot. The good news is that I got it working, and the problem seem to have been due to date formatting.

I have a Text Box that I update in the Page_Load event with the current date when the record is edited. The code looked like this:

TextBox varLastRevised2 = ((TextBox)(FormView1.FindControl("LastRevisedTextBox")));
varLastRevised2.Text = DateTime.Now.ToLongDateString();

For some reason, when this value needed to be placed back into the database, then the format of the date was not recognised. So I have changed the code to the following:

TextBox varLastRevised2 = ((TextBox)(FormView1.FindControl("LastRevisedTextBox")));
varLastRevised2.Text = DateTime.Now.ToString();

With this, it seem to be working.

The strange part is that I would think that there would be some sort of error if the date format was giving an error, but instead it just did not do anything. I am sure that the logs might have contained some info about this, but this is something I'll have to clear up.

Thanks for your advise in any case.

Best Regards
Jan

|||

This is maybe beacuse the database objects (e.g. tables, stored procedures,..etc) is created on the MVS with a user (say UserA), and now in the live server you are using another user (say UserB) who has the right permission to SELECT data (for example), but he can not see the table. Why? because it might be located in a schema that "UserB" can not access to it.

Make sure that the database user in the live server can see tables in the schema where you put the tables you got from development.

Good luck.

No comments:

Post a Comment