Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Web Part Question

  Asked By: Ervin    Date: Nov 19    Category: Sharepoint    Views: 843

I created a web part that has a text box, command button and a
label. User enters the ticker in the text box, and clicks on the
command button. On click event Web part code connects to a DB2
database, retrieve ticker price and display it on the label.
Everything works fine on my development PC. I logged in on the test
Sharepoint server as an admin and installed web part. The problem
starts now. If I try to browse that page from my PC I can see web
part, I can enter the ticker, click on the button, and the price is
displayed on the label. But when anyone else who is not
administrator on that server tries, they can see the web part, they
can enter the ticker, but when they click on the button, the page
get posted and and label is blank. It looks that Web part doesn't
even connects to the database. They don't get any errors though. Web
part is visible with entered ticker still in the text box, but label
is blank. Web part uses the same hardcoded UserID and password to
connect to a database. Any ideas?



4 Answers Found

Answer #1    Answered By: Leif Cardenas     Answered On: Nov 19

What are you doing with exceptions in your code? It’s likely that you’re capturing and throwing away an exception that occurred. Is there any place that you have a catch(){} block without any code  to rethrow the exception or draw the exception on the screen?

Answer #2    Answered By: Jasper Hatfield     Answered On: Nov 19

I have Try Catch, and on Catch I have error to be displayed on the label. Like this



strSql = "select Price from security where ticker  ='" & txtTicker.text.tostring.trim & "'"



Catch e As Exception

lblMsg.Text = e.Message



End Try

Still no exception, and no data returned. It should be something related to permissions, because it works  for people who are admins on Sharepoint server. By the way database server  (DB2) is on another box

Answer #3    Answered By: Rashawn Hopper     Answered On: Nov 19

… you’ll want to make sure that the label  actually gets added to the output stream. (this.Controls.Add(lblMsg))

You may also want to make sure that the try/catch encompasses everything in the method. How are you rendering? (RenderWebPart or CreateChildControls())

Are you writing a web  part or a user  control?

Answer #4    Answered By: Horace Coffey     Answered On: Nov 19

Thanks again for your response. label  gets rendered because I see warning inside label that i use to notify user  that needs to provide ticker  if they leave box  empty. Also everything works  fine if I run it or somebody who is admin  on the Sharepoint server(someone with elevated rights). I don't understand why I can run it, and another person can't when we are logging to the database  with the same UserID and Password.

Didn't find what you were looking for? Find more on Web Part Question Or get search suggestion and latest updates.