Loading

Database Application

Submitted by: 
Visitors have accessed this post 7444 times.




this is just a simple database query developed during my lunch break =)
hope u like it =)


Tags: 

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

I have reviewed your code.
It's nice but there is a problem with interacting COM objects with .NET objects.

In your example, you interopped Microsoft ActiveX DataObjects with your .NET application. Microsoft ActiveX Data Object is a COM library.

As we all know, much of the previous COM implementations (VB6, VC++6 etc) had been replaced or updated when .NET was introduced.

So instead of creating an ADODB.Recordset object for Inserting new records,
you can just use OleDbCommand to the the record insertion.

Example:

Using cmd as New OleDbCommand
cmd.Connection = conn
cmd.CommandText = "Insert into table SET column =@value"
cmd.Parameters.Add("@value", OleDbType.Varchar).Value = value
cmd.ExecuteNonQuery()
End Using

Also using OleDbCommand parameters reduce SQL injection attacks, which makes your application safer.

Although COM and .NET interop is possible, for optimization, if it is possible in .NET, do it in .NET.

jaysfall's picture

i agreed with you bro..
we can use dis instead of adodb.recordset.
for me, i prefer, odbcconnection than oledbconnection
for example..
import system.data.odbc

Dim myconnection = New System.Data.Odbc.OdbcConnection("dsn=SampleDatabase")
dim myRecordset as new odbcConnection

with myRecordset
.connection=myconnection
.commandText="Insert into tblname(Fname)values(''"& txtFname.text &"')
.executeNonQuery()
End with

thats it!So simple..No need of any adds-on References.hehe
GodBless

Consultant / .Net Developer

::jayxceleste@ymail.com::

+09059769698

cedrick blas's picture

actually ur both correct guys.. where in vb.net so well gonna use ADO.net

ill just post this code because some user ask me ho to use ADO (ADODB.recordset) in inserting records.. so this was just a help =) hehehe

soon ill post my latest project =) Quiz Bee system

i agreed with sir arjay..

Happy new year

woe tnx sir for the comment =)
but i prefared using recordset in inserting records but anyways this is just an example of my work. Yes, thanks for the info that OleDbCommand parameters reduce SQL injection attacks. Im just new hir so I need your help in programming =)

charle2364's picture

sir cedrick, i kinda like your post, it fits on my current project.. i am new in VB.net and still studying it. i quoted the code here:

rs = New ADODB.Recordset
rs.Open("Select * from administrator", cnstring, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

rs.AddNew()
rs("username").Value = txtusername.Text
rs("password").Value = txtpassword.Text
rs.Update()

MsgBox("Save!", MsgBoxStyle.Information, "Save")
txtpassword.Text = ""
txtusername.Text = ""

gridview1.Refresh()

i just want to ask what is the meaning of this line:

rs = New ADODB.Recordset
rs.Open("Select * from administrator", cnstring, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

thanks alot!

i just transferd mah code in vb 6 to .net
but anyways...

in this line

rs = New ADODB.Recordset
rs.Open("Select * from administrator", cnstring, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

the recordset open and select what table(administrator table) to be used =)

can u please teach me how to work with ado in my program??/

cedrick blas's picture

activex design object :) sa VB ba? kasi pwede rin ADO sa .net

Add new comment