CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.dotnetnuke.getting_started Tags:
Item Type: NewsGroup Date Entered: 6/9/2004 2:25:25 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 0 Views: 8 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages 1 |< << Go >> >|
lilryno
Asp.Net User
SELECT * FROM WHERE and filling a DataSet6/9/2004 2:25:25 AM

0/0

Hi,

In a DNN custom module I'm making I succesfully filled a DataSet with information from a MS Access Database. I've simply copied ALL the contents of the database into the dataset. I'm wondering, however, how to only copy certain members of the database into the dataset. I've tried using a Select From Where statement to no avail. Here is the code that works (but grabs the whole database). Note the database file is "arpt.mdb" and the only table is named "arpt":

Dim testdb As New OleDb.OleDbConnection
Dim GetTest As New OleDb.OleDbCommand
Dim TestAdapter As New OleDb.OleDbDataAdapter
Dim Testds As New DataSet

testdb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataSourcePath & "arpt.mdb"
GetTest.CommandText = "SELECT * FROM arpt"
GetTest.Connection = testdb
TestAdapter.SelectCommand = GetTest

testdb.Open()

TestAdapter.Fill(Testds, "arpt")

testdb.Close()

What I would like to do, however, is have it select records from the database where field "ICAO" is the same as a variable in my program "dicao". I would think if I changed the code above like this:

GetTest.CommandText = "SELECT * FROM arpt WHERE icao = dicao"

would do the trick but it's not working. I'm sure it's just a formatting error on my part. Can somebody help me with this? Many thanks...


DotNetNuke Bronze Benefactor
scottrait
Asp.Net User
Re: SELECT * FROM WHERE and filling a DataSet6/9/2004 1:31:07 PM

0/0

The easiest thing to do would be to make icao a parameter in your SQL statement and then set the information from dicao to fill that parameter. If you could give a little more detail on how it's getting the information from dicao I'd be happy to help you write it.
lilryno
Asp.Net User
Re: SELECT * FROM WHERE and filling a DataSet6/9/2004 1:58:53 PM

0/0

Thanks! dICAO is a variable that is filled in by the user in a textbox. So I just make:

dICAO = textbox18.text

So the user lets me know what field they are interested in and I want to populate my dataset from the database with all records that have FIELD "ICAO" equal to dICAO. Thanks for the help! I'm not very familiar with SQL.
DotNetNuke Bronze Benefactor
scottrait
Asp.Net User
Re: SELECT * FROM WHERE and filling a DataSet6/9/2004 2:35:00 PM

0/0

You can make ICAO = @whatever and then set the @whatever to be textbox18.text. Be careful with using textboxes for user input to a SQL statement. There's plenty of examples out there on how to protect for SQL injection.
lilryno
Asp.Net User
Re: SELECT * FROM WHERE and filling a DataSet6/9/2004 2:49:31 PM

0/0

Just to see if I understand you correctly, I should change my code to:

@whatever = textbox18.text
testdb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataSourcePath & "arpt.mdb"
GetTest.CommandText = "SELECT * FROM arpt WHERE icao = @whatever"
GetTest.Connection = testdb
TestAdapter.SelectCommand = GetTest

testdb.Open()

TestAdapter.Fill(Testds, "arpt")

Thanks again for the help.
DotNetNuke Bronze Benefactor
scottrait
Asp.Net User
Re: SELECT * FROM WHERE and filling a DataSet6/9/2004 3:21:37 PM

0/0

I don't think you can do the @whatever = textbox18.text. I've never tried it though. I always use something like GetTest.Parameters.Add("@whatever", textbox18.text)
6 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

problem with grid view - ng.asp-net-forum.web_parts_and_personalization ... ... da = new SqlDataAdapter(select, conn); da.Fill(ds, "Todolist"); Gridview. ... telll me where i need to change or what's wrong here.. siva_sm. Asp.Net User ...
Data Presentation Controls ... Presentation Controls. Re: Filling a DataSet using SELECT FROM WHERE. Re: Filling a DataSet using SELECT FROM WHERE. Re: Filling a DataSet using SELECT FROM WHERE ...
Unable to fill dataset - MSDN Forums ... SQL Server Compact Edition " Unable to fill dataset. Subscribe to RSS " ... success to do a select command against the dataadapter and then fill a dataset. ...
Walkthrough: Filling a Dataset with Data The dataset is filled with data by calling the Fill method of a TableAdapter. ... Select Database on the Choose a Data Source Type page, and then click Next. ...
DbDataAdapter.Fill Method (DataSet, String) (System.Data.Common) The Fill method retrieves the data from the data source using a SELECT statement. ... The Fill method supports scenarios where the DataSet contains multiple DataTable ...
Class: Sequel::Dataset ... to fill the columns cache with the column information when ... (price < 100).sql #=> "SELECT * FROM items WHERE ((category = 'software') AND (price < 100) ...
DataSet Vs. DataReader Ah, the DataSet. It can be filled and ready to go in just 3 lines of code, and ... "select * from mytable;",conn); DataSet s = new DataSet(); a.Fill(s) ...
Sample Chapter from Programming Microsoft® Visual Basic® .NET (Core ... ... and defined its SELECT command, you can use the object to fill an ... ( For example, you might have filled the DataSet manually via code without using a ...
how many data size to fill in DataSet - MSDN Forums I have 5 million record have to select to dataset but it dosn't work ... yeah a 5 million row dataset resident in memory is going to be a little unwieldly ...
Forms in HTML documents The SELECT element creates a menu, in combination with the OPTGROUP and ... A form data set is a sequence of control-name/current-value pairs constructed from ...
Univariate Gap Filling ... in Result, user can compare the gappy and dataset with missing values filled-in. ... percentage of the dataset variance used to fill the gaps is written ...



 
All Times Are GMT