Hi, I’m having trouble with my code and I’m starting to get lost. The Program takes the country that’s been typed in to the textbox and when the query button is clicked the program queries an access database for all records that contain the selected country. I think that part works, but I’m having trouble with the output. I want to display only certain fields of the record in a multiline text box, each matching record to a new line, like this…
Bob, UK, 99946, red
Joe, UK, 87777, Blue
Mary, UK, 48565, green
The database I name is TestDB, the table is InfoTable and the fields are Ename, Region, Enumber, Ecolour. Here’s the code… - Imports System.IO
-
Imports System.Data
-
Imports System.Data.OleDb
-
Public Class Test
-
Dim myString As String
-
-
Private Sub Test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
-
End Sub
-
-
-
Private Sub butQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butQuery.Click
-
myString = txtRegion.Text.ToString()
-
Dim cs As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\VB\Test\TestDB.mdb"
-
Dim cn As New OleDb.OleDbConnection(cs)
-
Dim dt As New DataTable
-
Dim dSet As New DataSet
-
Dim sqlString As String
-
-
sqlString = "SELECT Ename, Enumber, Ecolour FROM CMSDB WHERE Region = '" & myString & "'"
-
Dim cmd As New OleDb.OleDbCommand(sqlString, cn)
-
cmd.Parameters.Add("@myString", OleDb.OleDbType.VarChar, 30).Value = myString
-
Dim da As New OleDb.OleDbDataAdapter(cmd)
-
da.Fill(dt)
-
-
End Sub
-
-
End Class
Now thats the code and as far as I know it works ok, but when I try the code for the output to the multiline textbox it doesn’t work so good. Here’s the code… (this code goes right under the da.Fill(dt) above… -
-
-
For Each dRow As DataRow In dSet.Tables("myTable").Rows
-
For Each dCol As DataColumn In dRow
-
txtQuery.Text = txtQuery.Text & " " & dCol.ToString()
-
Next dCol
-
-
txtQuery.Text = txtQuery.Text & vbCrLf
-
Next dRow
If anyone can help me get the code working that would be great.
I also seem to get this error “Expression is of type 'System.Data.Da taRow', which is not a collection type.” The error pops up on dRow from this line… - For Each dCol As DataColumn In dRow
Could someone help me get the output code working?
Cheers,
Jack
0 1529 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Joel Finkel |
last post by:
Folks,
I have a form that has several TextBoxes, some of which have the TextMode set to MultiLine. Each is pre-loaded with data from a database. The user is allowed to modify each entry.
The problem is that only the modified data from the SingleLine TextBoxes are returned. The original data are returned for the MultiLine TextBoxes. Also, if the page is sent to the server (for validation, for instance), only the modified data for the...
|
by: Eric |
last post by:
Visual C++ 2005 Express
MVP's and experience programmer's only please!...
I need to get the number of lines in a textbox so I can insert them into a
listview. The text comes from my database and is unformatted. I display the
text to my user in the listview. The textbox I create logically in the
program, and I initialize the correct properties for a normal multiline
editor.
|
by: Luke Herbert |
last post by:
I am very new to C# and have been trying to get to grips with it by
writing a small tool to detect a USB key being inserted and then backup
user specified files to the key.
I have written some code and been able to construct a WMI query and can
even get the output of this query to display to the console but not to
a TextBox on my form. I fear it is embarassingly obvious but having
looked at a whole heap of books (not read them in their...
|
by: Jeff |
last post by:
hey
asp.net 2.0
In my website I've got a textbox with TextMode=MultiLine. The user can enter
text that contain "new line"...
But to displays this I'm also using a textbox with TextMode=MultiLine and
ReadOnly=True.
The textbox displays a ugly border arround the textbox, including scrollbars
|
by: Mike Collins |
last post by:
I someone can please help, I am about at an end in trying to figure this out.
I am adding some dynamic controls to my page (I found out that I was supposed
to be doing that in the oninit event, which I am). I now want to read the
text/values of those controls. I have found out that I can read the values if
I wait until Page_Load, but then I have the same questions showing up again
(along with the new questions) and I do not want them to....
| |
by: Ian Tedridge |
last post by:
If I have 3 textboxes on a form plus 1 multiline textbox.
How can I add the text from textbox 1 to 3 to the multiline textbox ?
I can add the 3 textbox contents to one line of the multiline textbox, but
need each text line to appear on seperate lines.
this is driving me crazy, please help
|
by: Mike |
last post by:
I am trying to write a little program for my own use using VB2005 express edition.
I have a list of peoples names in a file that I read into an array of strings. I am using a multiline textbox
to enter new, edit existing, and view the names in the array. This all works well, but now I want to be able
to select one more names from the list displayed in the multiline textbox then click a button to copy the
selected names into another list so...
|
by: anniebai |
last post by:
Please help me with writing a RowUpdating function in C#, I don't know how to grab the current field's value and also get the old value for one of keys (which is ProjectName for editing) of the selected row. I've tried:
e.Keys.Count, e.OldValues.Count, e.NewValues.Count -----------> all give zero
Some said if TemplateField is used, e.Keys and Oldvalues, NewValues are all empty. Then what suppose to be used in such case?
Thanks for any...
|
by: =?Utf-8?B?anAybXNmdA==?= |
last post by:
I want to plant an Easter Egg in our software.
We have a TextBox that is multiline and used to display all sorts of
messages on the screen for our operators based on database queries and such.
The Easter Egg I want to create would send a dump of the data for a
particular part number to the screen when a certain secret combination of
characters is pressed. If it works out well, I can actually impliment it on
our production floor.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |