| | |
DB and :Net questions
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2006
Posts: 1
Reputation:
Solved Threads: 0
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.
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.
>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?
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?
*Voted best profile in the world*
•
•
Join Date: Nov 2006
Posts: 32
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Nov 2006
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
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.
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
![]() |
Similar Threads
- Help Iis With Lan !!!!!!!!!!!!!!!!!! (ASP.NET)
- How do you switch between forms in vb.net? (VB.NET)
- HTML newbie problem!! (JavaScript / DHTML / AJAX)
- New Style (DaniWeb Community Feedback)
- retrieving ids from dynamically created controls in asp.net (ASP)
Other Threads in the VB.NET Forum
- Previous Thread: Serial port programming
- Next Thread: login Access Level
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
"crystal .net .net2005 30minutes 2008 access add application arithmetic array assignment basic binary box button buttons center code combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees error excel firewall folder image images isnumericfuntioncall listview login math memory mobile ms mssqlbackend mysql navigate net opacity page pan peertopeervideostreaming picturebox picturebox1 plugin port print printing printpreview problem problemwithinstallation project record reports" reuse save savedialog serial server sorting sql storedprocedure string structures studio temp textbox timer updown upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf






