Error: object reference not set to an instance of an object [Resolved]

Posted by Thiru under VB.NET on 3/22/2012 | Points: 10 | Views : 2507 | Status : [Member] | Replies : 2
Hi please help & save my time:

I am getting an Error: object reference not set to an instance of an object

Here is the code:
note: codeTextBox.Text= CBE10000001

I am getting the error while calling the function LoadBusinessManDetails:
(Its not even going to that function. just throw the error exactly on the following line)
CALL mSybergy.LoadBusinessManDetails(CodeTextBox.Text)


my function is:

Public Function LoadBusinessManDetails(ByVal vCode As String) As DataSet
Dim cmd As MySqlCommand = Nothing
Dim adp As MySqlDataAdapter = Nothing
Dim ds As New DataSet
Try
connection()
cmd = New MySqlCommand("SP_SelectWorker", Con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("vWMC", MySqlDbType.String).Value = vCode
adp = New MySqlDataAdapter(cmd)
adp.Fill(ds)
Con.Close()
Return ds
Catch ex As Exception
Throw ex
Finally
If Con.State = ConnectionState.Open Then
Con.Close()
End If
cmd.Dispose() : adp.Dispose()
End Try

End Function



please help me to save my time.
regards,
thiru.




Responses

Posted by: Thiru on: 3/23/2012 [Member] Starter | Points: 25

Up
0
Down

Resolved
Hi Himanshu Manjarawala,

Thanks for your reply and your valuable time here.

Actually i tried with the following lines and its working fine now:

Dim objload As SYBERGY.WorkerClass = New SYBERGY.WorkerClass

CodeTextBox.Text = CallSearchForm()
BranchLDataset = objload.LoadBusinessManDetails(CodeTextBox.Text)
LoadData()


We should create the object with new instance using the keywork New
like: dim objload as new sybergy.workerclass
instead of dim objload as sybergy.workerclass

Anyway thanks for your valuable time.


Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/23/2012 [Member] Bronze | Points: 25

Up
0
Down
Ok thiru,

change this line
codeTextBox.Text= "CBE10000001 "

and try again....


Mark this as answer, if it helps you...........

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response