IMAC
New member
- Joined
- May 16, 2010
- Messages
- 2
- Programming Experience
- 1-3
Hi
I have just started programming VB.net as i must make a program for a course at the university.
I am not familiar with it and i am having some problems trying to understand how the connection and SQL select commands works here.
Well, i am using FireBirdSQL as a database so i use this imports:
Appart from it i declare this vars:
And then i make the selection i want to get the data:
The question is that i have seen other code that uses this other method:
What is a DataAdapter? what advantages has it?
Why it uses da.SelectCommand.Parameters.Add("@id", id)? what does it do?
Whats the difference between ExecuteReader() and it?
What does da.Fill(ds, "mytable") do? What is "mytable"?
And about ds.Tables("mytable")?
I have tried to find information about this points on google, but i couldn't find anything with enought information for a noob...
Can you help me?
PD: sorry for my writting mistakes Just not my language.
I have just started programming VB.net as i must make a program for a course at the university.
I am not familiar with it and i am having some problems trying to understand how the connection and SQL select commands works here.
Well, i am using FireBirdSQL as a database so i use this imports:
VB.NET:
Imports FirebirdSql.Data.FirebirdClient
Imports FirebirdSql.Data.Isql
Appart from it i declare this vars:
VB.NET:
Dim cmd As FbCommand
Dim dr As FbDataReader
Dim bbdd As BaseBBDD
And then i make the selection i want to get the data:
VB.NET:
bbdd = New BaseBBDD(True)
cmd = bbdd.crearComando("select * from cliente")
dr = cmd.ExecuteReader()
While dr.Read()
Console.WriteLine("{0} Nombre: {1} DNI: {2}", dr(0), dr(2), dr(1))
WriteLine()
End While
Console.ReadLine()
The question is that i have seen other code that uses this other method:
VB.NET:
bbdd = New BaseBBDD(True)
Dim ds As New DataSet()
Dim da As FbDataAdapter = bbdd.crearDataAdapter("SELECT * FROM mytable WHERE id >= @id")
da.SelectCommand.Parameters.Add("@id", id)
da.Fill(ds, "mytable")
Return ds.Tables("mytable")
What is a DataAdapter? what advantages has it?
Why it uses da.SelectCommand.Parameters.Add("@id", id)? what does it do?
Whats the difference between ExecuteReader() and it?
What does da.Fill(ds, "mytable") do? What is "mytable"?
And about ds.Tables("mytable")?
I have tried to find information about this points on google, but i couldn't find anything with enought information for a noob...
Can you help me?
PD: sorry for my writting mistakes Just not my language.