Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm using web services to connect to a sql server. when I run the web service and one of the webmethods, I get dataset back that looks to be giving me good data. However, in my windows form, when I try to use this ws and dataset, I get a system.nullreferenceexception error. I don't understand what it is telling me because when I run the web service by itself, I"m getting good data to that point. I've done the update web referrence in my project but still no luck. can somone point me in the right direction please.

 

Here is what I'm trying to do. pull the info into a drop down list box.

 

       ds = ws.fnSurgeonSEL(surgeon, childintTblParentInfoId)


       With Me.lbSurgeon
           .DataSource = ds.Tables("SurgeonSEL")
           .DisplayMember = "vcSurgeonName"
           .ValueMember = "intTblSurgeonId"
       End With

 

ws is what I used toward the top of my form to point to the web refference.

 

thanks

shannon

JvCoach23

VB.Net newbie

MS Sql Vet

Posted

More info on dataset problem

 

A little more info would likely help. Here is a clip from the web service

 

   <WebMethod()> Function fnSurgeonSEL(ByVal intTblSurgeonId As Integer, ByVal intTblPersonalInfoId As Integer) As DataSet
       With Me.spSurgeonSEL
           .Parameters("@intTblSurgeonId").Value = intTblSurgeonId
           .Parameters("@intTblPersonalInfoId").Value = intTblPersonalInfoID

           Me.cnSql.Open()
           .ExecuteNonQuery()
           Me.cnSql.Close()
       End With

       Me.daSurgeonSEL.Fill(Me.dsSurgeonSEL, "SurgeonSEL")
       Return Me.dsSurgeonSEL
   End Function

 

 

 

I'm using web services to connect to a sql server. when I run the web service and one of the webmethods, I get dataset back that looks to be giving me good data. However, in my windows form, when I try to use this ws and dataset, I get a system.nullreferenceexception error. I don't understand what it is telling me because when I run the web service by itself, I"m getting good data to that point. I've done the update web referrence in my project but still no luck. can somone point me in the right direction please.

 

Here is what I'm trying to do. pull the info into a drop down list box.

 

       ds = ws.fnSurgeonSEL(surgeon, childintTblParentInfoId)


       With Me.lbSurgeon
           .DataSource = ds.Tables("SurgeonSEL")
           .DisplayMember = "vcSurgeonName"
           .ValueMember = "intTblSurgeonId"
       End With

 

ws is what I used toward the top of my form to point to the web refference.

 

thanks

shannon

JvCoach23

VB.Net newbie

MS Sql Vet

Posted
Have you set ws to a valid instance of the web service?

 

 

yes.. I believe I have

 

Public Class frmDDSurgeonList
   Inherits System.Windows.Forms.Form

   Dim ws As New wsMedicalCE.dataAccess
   Dim childintTblParentInfoId As Integer

JvCoach23

VB.Net newbie

MS Sql Vet

Posted
yes.. I believe I have

 

Public Class frmDDSurgeonList
   Inherits System.Windows.Forms.Form

   Dim ws As New wsMedicalCE.dataAccess
   Dim childintTblParentInfoId As Integer

 

when i typed in the following line, the intellesense was prompting me for my paramter names for the function

 

ds = ws.fnSurgeonSEL(surgeon, childintTblParentInfoId)

JvCoach23

VB.Net newbie

MS Sql Vet

Posted

in working on it more.. I took the same webservice and way I was trying to populate the list box and put it in another project, and it worked fine.. but when I try to do it in this project, I get this error.

 

An unhandled exception of type 'System.NullReferenceException' occurred

 

does this help.. can someone tell me what I've got set wrong with this project..

 

thanks

JvCoach23

VB.Net newbie

MS Sql Vet

Posted

I added the following line to the code below

If dsAnesthesiologist Is Nothing Then

MsgBox("It's blank")

Else

With Me.lbAnesthesiologist

.DataSource = dsAnesthesiologist.Tables("AnesthesiologistSEL")

.DisplayMember = "vcAnesthesiologistName"

.ValueMember = "intTblAnesthesiologistId"

End With

End If

 

I did a breakpoint so I coudl watch and it does not show dsAnesthesiologist as equal to nothing.. it jumps over to the else. Here is what I'm using to instantiate teh webservice..

 

Dim ws As New wsMedicalCE.dataAccess

 

i'm using that same line in anther form with a different function and that one is working.

 

Hope you have some ideas

JvCoach23

VB.Net newbie

MS Sql Vet

Posted

.DataSource = dsAnesthesiologist.Tables("AnesthesiologistSEL")

 

is the line that is causing the exception. The names are all correct.. I've checked those several times. I also took the sub that is doing this, copied it into another form on this project and pointed it to a listbox called listbox3 instead of lbAnesthesiologist and it worked great. So I'm not sure what I'm doing wrong.

JvCoach23

VB.Net newbie

MS Sql Vet

Posted

It's working now

 

very sorry to all who spent time trying to figure this one out for me. I figured out what the problem was. I was passing in a value from another form, using the public sub new with mybase.new and I forgot to put the initializecomponent() in there.. that was what was causing me the problem.. I created a new form and started with the basics and worked up to where my other form stopped working.. and there the problem was.. again so sorry about that

JvCoach23

VB.Net newbie

MS Sql Vet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...