Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Error : system.nullreferenceexception (http://www.velocityreviews.com/forums/t754381-error-system-nullreferenceexception.html)

Ruchi22 09-23-2011 09:14 AM

Error : system.nullreferenceexception
 
Hello..I am developing a windows application in vb.net and getting an error of system.nullreference exception.
I am trying to insert data in the database, insertion occurs in the first go. But, when i stop the porgram and re-run, i get the exception. Can anybody please help me with this ? Here is the code :

Imports System.Data
Imports System.Data.OleDb
Imports System.EventArgs
Imports System.Data.OleDb.OleDbCommand
Imports System.Data.OleDb.OleDbConnection

Public Class ContactInfo_supp
Inherits System.Windows.Forms.Form

Dim Message As String
Dim cn As OleDbConnection
Dim cmd As OleDbCommand



Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click

Try
'MsgBox("Open")
cn = New OleDbConnection("Provider=microsoft.jet.oledb.4.0; Data Source=E:\Project-Hemtech\HemDatabase1.mdb;")
cn.Open()
cmd = New OleDbCommand("insert into contactinfo(usertype,compname,compadd,compcity,com ppin,compphcode,compph,compfaxcode,compfax,compmai l,compsite,compregoff,compfact,products,interest,r egion,place,contper1,comprole1,compemail1,contnum1 ,ext1,mobnum1,contper2,comprole2,compemail2,contnu m2,ext2,mobnum2,contper3,comprole3,compemail3,cont num3,ext3,mobnum3,weeklyoff,vat,cst,pan,ecc,commis sionerate,range,division,servicetax,bankname,bankb ranch,accnum,rtgs,instrname,modelnum,installdate,a mc,callibration,period,expdate) values ('Supplier','" & textBox1.Text & "','" & textBox2.Text & "','" & textBox39.Text & "','" & textBox41.Text & "','" & textBox45.Text & "','" & textBox3.Text & "','" & textBox4.Text & "','" & textBox46.Text & "','" & textBox5.Text & "','" & textBox6.Text & "','" & textBox7.Text & "','" & textBox8.Text & "','" & textBox42.Text & "','" & textBox43.Text & "','" & ComboBox1.SelectedItem.ToString() & "','" & textBox44.Text & "','" & textBox9.Text & "','" & textBox10.Text & "','" & textBox47.Text & "','" & textBox11.Text & "','" & textBox12.Text & "','" & textBox13.Text & "','" & textBox18.Text & "','" & textBox17.Text & "','" & textBox48.Text & "','" & textBox16.Text & "','" & textBox15.Text & "','" & textBox14.Text & "','" & textBox23.Text & "','" & textBox22.Text & "','" & textBox49.Text & "','" & textBox21.Text & "','" & textBox20.Text & "','" & textBox19.Text & "','" & textBox50.Text & "','" & textBox25.Text & "','" & textBox26.Text & "','" & textBox27.Text & "','" & textBox28.Text & "','" & textBox29.Text & "','" & textBox30.Text & "','" & textBox31.Text & "','" & textBox32.Text & "','" & textBox33.Text & "','" & textBox34.Text & "','" & textBox35.Text & "','" & textBox36.Text & "','" & textBox37.Text & "','" & textBox38.Text & "','" & dateTimePicker1.Text & "','" & ComboBox2.SelectedItem.ToString() & "','" & ComboBox3.SelectedItem.ToString() & "','" & textBox40.Text & "','" & dateTimePicker2.Text & "')", cn)
cmd.ExecuteNonQuery()

MsgBox("Your Account Created Successfully ")

Dim f9 As New Action()
f9.Show()
Me.Hide()

Catch myException As Exception

MsgBox("No Record Inserted" + myException.ToString())

Finally
'MsgBox("Closing Connection")

cn.Close()
End Try

End Sub


All times are GMT. The time now is 10:48 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.