Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close() not found 1

Status
Not open for further replies.

A1Pat

IS-IT--Management
Jun 7, 2004
454
US
Hello,

I'm getting this error message:
System.MissingMemberException: Public member 'Close' on type 'OleDbCommand' not found.

And here is my db code
Code:
dim dbconn,sql,dbcomm
			dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & server.mappath("database/store.mdb"))
			dbconn.Open()
			'db command'
			sql = "Insert into Preprogram_doc (" _
				& "cname, caddress, ccity, cstate, czip, cphone, days, getdate" _
				& ") Values (" _
				& "'" & txtCName.Text & "','" & txtCAddress.Text & "','" & txtCCity.Text & "','" & ddl_states.SelectedItem.Value & "','" & txtCZip.Text & "','" & txtCPhone.Text & "','" & ddlDays.SelectedItem.Value & "','" & now() & "')"
			dbcomm = New OleDbCommand(sql,dbconn)
			'DataReader: OleDbDataReader class is used to read a stream of records from a data source'
			dbcomm.ExecuteNonQuery()
			'close DataReader and db connection'
			dbcomm.Close()
			dbconn.Close()

I checked around but found no particular help for the situation. Except I found most of the similar code also utilizing [bold]rs.Close()[/bold] as well.
 
See, that's a funny thing cause I couldn't find that either. However, I learned that code from online somewhere and it worked with some other example before, as I remember. This's weird!
 
The Close method you have for the Connection is fine, but you don't need to do anything with your command (and as far as I recall have never needed to).

You could set it to Nothing and then call it's Dispose method but I wouldn't worry about it as the Connection will take care of the database side of things and the garbage collector will worry about the memory side.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
I don't know why but when I modify a little bit here:

Code:
dbcomm.ExecuteReader()
to
Code:
dbread=dbcomm.ExecuteReader()

the problem solved!

If you understand why, please clarify that for me too please.
 
What do you mean by the problem is solved? It will still error if you call "dbcomm.Close()" as that method doesn't exist.

However, if you make the modification you have done, it means you will have a reader named "dbread" that you can loop through. If this is what you are trying to do, you might want to check out the first example in faq855-5662.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Ooopss! You're right!
I'm sorry about forget to tell you that I also change that line
Code:
dbcomm.Close()
to
Code:
dbread.Close()

Sorry about that!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top