jvcoach23 Posted April 1, 2004 Posted April 1, 2004 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 Quote JvCoach23 VB.Net newbie MS Sql Vet
jvcoach23 Posted April 1, 2004 Author Posted April 1, 2004 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 Quote JvCoach23 VB.Net newbie MS Sql Vet
Administrators PlausiblyDamp Posted April 1, 2004 Administrators Posted April 1, 2004 Have you set ws to a valid instance of the web service? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
jvcoach23 Posted April 1, 2004 Author Posted April 1, 2004 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 Quote JvCoach23 VB.Net newbie MS Sql Vet
jvcoach23 Posted April 1, 2004 Author Posted April 1, 2004 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) Quote JvCoach23 VB.Net newbie MS Sql Vet
jvcoach23 Posted April 1, 2004 Author Posted April 1, 2004 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 Quote JvCoach23 VB.Net newbie MS Sql Vet
jvcoach23 Posted April 2, 2004 Author Posted April 2, 2004 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 Quote JvCoach23 VB.Net newbie MS Sql Vet
Administrators PlausiblyDamp Posted April 2, 2004 Administrators Posted April 2, 2004 Are the field and table names spelled correctly (a favourite mistake of mine ;)). Also if you are stepping through the code which line actually causes the nullreferenceexception? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
jvcoach23 Posted April 2, 2004 Author Posted April 2, 2004 .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. Quote JvCoach23 VB.Net newbie MS Sql Vet
jvcoach23 Posted April 2, 2004 Author Posted April 2, 2004 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 Quote JvCoach23 VB.Net newbie MS Sql Vet
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.