Reputation: 13811
Hi i want to create a application in VB. And i have created all the forms, and in the meantime i want one form to connect to database(lets say form name, DB). I have created it and connected to Oracle. Now in that form (DB) i want to search the Oracle table for its ID(which have been manually created by me using SQL commands). And if the ID matches with the user entered input, then all other details of that ID(say name, address) should appear in that form! How to do this? Any idea, i'm very newbie in VB, so kindly help me! It will be good even if you put the code snippet :)
Please say me how to do this?
Upvotes: 0
Views: 1047
Reputation: 1051
For an introduction on connecting to an Oracle DB from VB .NET you could take a look at this tutorial. The technique described in this article is a simple and fast technique for getting started, however for production applications I would strongly recommend a mapper such as Nhibernate. Once you have performed your SQL select statement against the Oracle DB you will need to copy the data that you have read into an object to pass up to the UI layer:
Dim dr As OracleDataReader = cmd.ExecuteReader() ' VB.NET
Dim userObject As New User()
Dim name As String = dr.Read()
Dim address As String dr.Read()
userObject.Name = name
userObject.Address = address
Once you have read the required data into memory you could use data binding to display the required data. Read more about it in this article. All you should need to do is create a control on your VB.NET form, and set the datasource the your userObject that you have read in from the database.
Upvotes: 2
Reputation: 1549
what have you been using for your commands? you would pass the ID with the command so the query would only return the results that you would want. So the query would look something like "select * from mytable where ID = 1". the id of 1 would be from the vb application which you would either pass it as a parameter or build the query in the application and just run the query as text. what have you so far?
Upvotes: 0