Women in Technology

Hear us Roar

  .NET Streams Explained
Subject:   Object reference not set to an instance of an object
Date:   2006-02-12 22:21:20
From:   vivekgrs
Dim imgstream As FileStream
Dim imglen As Integer
Dim contenttype As String
Dim name As String
Dim imgbin As New Byte()
Dim param1, param2, param3 As OleDbParameter
imgstream = file1.PostedFile.InputStream
imglen = file1.PostedFile.ContentLength
contenttype = file1.PostedFile.ContentType
name = file1.Value
imgbin = imglen

Dim cnn As OleDbConnection
Dim cmm As OleDbCommand
cnn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;datasource = c:\inetpub\wwwroot\tools\toolsdetails.mdb")
cmm.CommandText = "insert into image([name],[data],[content])values (@name,@data,@content)"
param1 = cmm.Parameters.Add("@name", OleDbType.Char)
param2 = cmm.Parameters.Add("@data", OleDbType.VarBinary)
param3 = cmm.Parameters.Add("@content", OleDbType.Char)
param1.Value = name
param2.Value = imgbin
param3.Value = contenttype

this is the codes i had used in vb.net. but it shows error "Object reference not set to an instance of an object". can give me idea about the errors.

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Object reference not set to an instance of an object
    2007-11-16 02:42:54  PraveenValla [View]

    You have used this "Dim cmm As OleDbCommand"

    Use this Dim cmm As New OleDbCommand