944,008 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1810
  • VB.NET RSS
Nov 26th, 2006
0

DB and :Net questions

Expand Post »
First of I am not engllish speaker so if something its off forgive me please.

Now on the topic, I have not touch VB in 4 or years and now changing from VB6 to VB 2005

Now I used to work with dataset on VB6 but the teacher is really.... patetic to said at best, and its making us use something like this.

conexion = "provider = microsoft.jet.oledb.4.0;data source= C:\Download\Anime.mdb"
Dim con As New System.Data.OleDb.OleDbConnection(conexion)
Dim adaptador As System.Data.OleDb.OleDbDataReader
consulta = "select Nombre, Tipo, Discos, Completa from CD where Nombre like '" + TextBox2.Text + "' "
Dim comando As New System.Data.OleDb.OleDbCommand(consulta, con)
con.Open()
adaptador = comando.ExecuteReader
While adaptador.Read
TextBox15.Text = (adaptador.Item(0))
TextBox14.Text = (adaptador.Item(1))
TextBox13.Text = (adaptador.Item(2))
RadioButton2.Checked = (adaptador.Item(3))
End While
adaptador.Close()
con.Close()

So far I have been able to read of database but I want to introduce things (currently working on this), delete and edit. Sadly for the moment I am short on time to finish this and other projects so a bit forced to ask for help.

Bedsides this I have 3 questions.

1.- is there a way to avoid typing all that each time I want to acces the database (example each button), and if so how.

2.- is there a better way to manipulate the database.

3.- oh yeah, in 1 I am taking a "type" of cd from another database, but instead of vb using the text to search for it, its using the value.
example db1. "type" "id" db2 "type" "name"... etc

In vb its taking the name from a combo box, but the datase its asking me from the id.

I know its to much bother even if its little the help or a link to somewhere it would help me a ton.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Xelloss is offline Offline
1 posts
since Nov 2006
Nov 26th, 2006
0

Re: DB and :Net questions

>is there a way to avoid typing all that each time I want to acces the database (example each button), and if so how.


Copy 'n' paste

> is there a better way to manipulate the database.

If it works don't worry about it.

>oh yeah, in 1 I am taking a "type" of cd from another database, but instead of vb using the text to search for it, its using the value.
example db1. "type" "id" db2 "type" "name"... etc

So have you created a relevant class?
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Nov 30th, 2006
0

Re: DB and :Net questions

1.- is there a way to avoid typing all that each time I want to acces the database (example each button), and if so how.

Ans: Declare the con, comando in the General Declarations section.
Set the Connection string and command text (con) in the Form_Load event instead of each button.

General Declarations:

Dim con As System.Data.OleDb.OleDbConnection
Dim comando As System.Data.OleDb.OleDbCommand
Dim adaptador As System.Data.OleDb.OleDbDataReader

Form_Load:
conexion = "provider = microsoft.jet.oledb.4.0;data source= C:\Download\Anime.mdb"
consulta = "select Nombre, Tipo, Discos, Completa from CD where Nombre like '" + TextBox2.Text + "'

con= New System.Data.OleDb.OleDbConnection (connexion)
comando= New System.Data.OleDb.OleDbCommand (consulta,con)

The rest of the code goes in the button for retrieving data.

2.- is there a better way to manipulate the database.
Ans: You can use a DataAdaptor and DataSet

3. Need more Explanation
Reputation Points: 10
Solved Threads: 0
Light Poster
sierrasoft is offline Offline
31 posts
since Nov 2006
Nov 30th, 2006
0

Re: DB and :Net questions

Click to Expand / Collapse  Quote originally posted by Xelloss ...
First of I am not engllish speaker so if something its off forgive me please.

Now on the topic, I have not touch VB in 4 or years and now changing from VB6 to VB 2005

Now I used to work with dataset on VB6 but the teacher is really.... patetic to said at best, and its making us use something like this.

conexion = "provider = microsoft.jet.oledb.4.0;data source= C:\Download\Anime.mdb"
Dim con As New System.Data.OleDb.OleDbConnection(conexion)
Dim adaptador As System.Data.OleDb.OleDbDataReader
consulta = "select Nombre, Tipo, Discos, Completa from CD where Nombre like '" + TextBox2.Text + "' "
Dim comando As New System.Data.OleDb.OleDbCommand(consulta, con)
con.Open()
adaptador = comando.ExecuteReader
While adaptador.Read
TextBox15.Text = (adaptador.Item(0))
TextBox14.Text = (adaptador.Item(1))
TextBox13.Text = (adaptador.Item(2))
RadioButton2.Checked = (adaptador.Item(3))
End While
adaptador.Close()
con.Close()

So far I have been able to read of database but I want to introduce things (currently working on this), delete and edit. Sadly for the moment I am short on time to finish this and other projects so a bit forced to ask for help.

Bedsides this I have 3 questions.

1.- is there a way to avoid typing all that each time I want to acces the database (example each button), and if so how.

2.- is there a better way to manipulate the database.

3.- oh yeah, in 1 I am taking a "type" of cd from another database, but instead of vb using the text to search for it, its using the value.
example db1. "type" "id" db2 "type" "name"... etc

In vb its taking the name from a combo box, but the datase its asking me from the id.

I know its to much bother even if its little the help or a link to somewhere it would help me a ton.
Hello,
if u want to run the Delete insert or update type queries then use the following code
1. make a connection string . as u make "conexion"
2. write code

dim cmd as new oledbcommand("Insert Query",conexion)
conexion.open()
cmd.executeNonQuery()
conexion.close()

Try this code it may run
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Anirudha is offline Offline
1 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Legal?
Next Thread in VB.NET Forum Timeline: login Access Level





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC