hi,
i am creating a form in my application which dynamically creates controls by getting information from a table in ms access database .now i would like it to get the text by using another table .
my code: - Private Sub frmDataEntry_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
-
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & Application.StartupPath & "\customer.mdb")
-
Dim cn1 As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & Application.StartupPath & "\customer.mdb")
-
Dim cmd As OleDbCommand
-
Dim dr As OleDbDataReader
-
Dim str As String
-
Dim txtBox As TextBox
-
Dim labl As Label
-
Dim pt As Point
-
Dim pt1 As Point
-
Dim cnt As Integer
-
Dim cnt1 As Integer
-
Dim siz As Size = New Size(200, 20)
-
Dim i As Integer
-
Dim ds As DataSet
-
Dim pbndTemp As Binding
-
-
Try
-
If cn.State = ConnectionState.Closed Then
-
cn.Open()
-
End If
-
-
Dim ad As New OleDbDataAdapter("SELECT FldAn FROM tblCustomFieldAnswers WHERE AcctNum='" & m_stracctnum1 & "' And CustID = " & m_intcustnum1 & "", cn)
-
ds = New DataSet
-
ad.Fill(ds, "tblCustomFieldAnswers")
-
-
str = "SELECT FieldName FROM tblCustomFields WHERE AcctNum='" & m_stracctnum1 & "'And CustID = " & m_intcustnum1 & ""
-
cmd = New OleDbCommand(str, cn)
-
dr = cmd.ExecuteReader
-
-
While dr.Read
-
-
pt = New Point(140, cnt + 10)
-
pt1 = New Point(10, cnt1 + 10)
-
txtBox = New TextBox
-
txtBox.Location = pt
-
txtBox.Size = siz
-
Me.Controls.Add(txtBox)
-
-
pbndTemp = New Binding("text", ds, "tblCustomFieldAnswers.FldAn")
-
txtBox.DataBindings.Add(pbndTemp)
-
-
labl = New Label
-
labl.Text = dr(i)
-
labl.Location = pt1
-
labl.Size = siz
-
Me.Controls.Add(labl)
-
-
cnt = cnt + (txtBox.Height + 15)
-
cnt1 = cnt1 + (txtBox.Height + 15)
-
-
End While
-
-
Catch ex As OleDbException
-
-
MessageBox.Show(ex.ToString())
-
-
End Try
-
If cn.State <> ConnectionState.Closed Then
-
cn.Close()
-
End If
-
-
End Sub
iam able to get text in the controls but it only reads one row and shows the same data in all the controls.
how should i loop it so that it reads throught the entire table and displays data from all the rows into the controls?
2 1863
hi,
i tried doing this. but now it only displays the data in the last control but all other controls are empty.can anyone help? - While dr.Read
-
-
pt1 = New Point(10, cnt1 + 10)
-
-
labl = New Label
-
labl.Text = dr(i) & ":"
-
labl.TextAlign = ContentAlignment.MiddleRight
-
labl.Location = pt1
-
labl.Size = lablsiz
-
Me.Controls.Add(labl)
-
-
pt = New Point(175, cnt + 10)
-
txtBox = New TextBox
-
txtBox.Location = pt
-
txtBox.Size = txtsiz
-
Me.Controls.Add(txtBox)
-
-
cnt1 = cnt1 + (labl.Height + 15)
-
cnt = cnt + (txtBox.Height + 15)
-
End While
-
-
'-------------------------------
-
If cn1.State = ConnectionState.Closed Then
-
cn1.Open()
-
End If
-
-
str1 = "SELECT FldAn FROM tblCustomFieldAnswers WHERE AcctNum='" & m_stracctnum1 & "' And CustID = " & m_intcustnum1 & ""
-
cmd1 = New OleDbCommand(str1, cn1)
-
dr1 = cmd1.ExecuteReader
-
-
While dr1.Read
-
-
-
txtBox.Text = dr1(i)
-
-
End While
got it done. - Try
-
If cn.State = ConnectionState.Closed Then
-
cn.Open()
-
End If
-
-
cn1.Open()
-
str1 = "SELECT FldAn FROM tblCustomFieldAnswers WHERE AcctNum='" & m_stracctnum1 & "' And CustID = " & m_intcustnum1 & ""
-
cmd1 = New OleDbCommand(str1, cn1)
-
dr1 = cmd1.ExecuteReader
-
-
-
str = "SELECT FieldName FROM tblCustomFields WHERE AcctNum='" & m_stracctnum1 & "'And CustID = " & m_intcustnum1 & ""
-
cmd = New OleDbCommand(str, cn)
-
dr = cmd.ExecuteReader
-
-
-
If dr1.HasRows = False Then
-
-
While dr.Read
-
pt1 = New Point(10, cnt1 + 10)
-
labl = New Label
-
labl.Text = dr(i) & ":"
-
labl.TextAlign = ContentAlignment.MiddleRight
-
labl.Location = pt1
-
labl.Size = lablsiz
-
Me.Controls.Add(labl)
-
pt = New Point(175, cnt + 10)
-
txtBox = New TextBox
-
txtBox.Location = pt
-
txtBox.Size = txtsiz
-
Me.Controls.Add(txtBox)
-
-
cnt = cnt + (txtBox.Height + 15)
-
cnt1 = cnt1 + (labl.Height + 15)
-
End While
-
-
Else
-
While dr.Read
-
pt1 = New Point(10, cnt1 + 10)
-
labl = New Label
-
labl.Text = dr(i) & ":"
-
labl.TextAlign = ContentAlignment.MiddleRight
-
labl.Location = pt1
-
labl.Size = lablsiz
-
Me.Controls.Add(labl)
-
While dr1.Read
-
pt = New Point(175, cnt + 10)
-
txtBox = New TextBox
-
txtBox.Location = pt
-
txtBox.Size = txtsiz
-
Me.Controls.Add(txtBox)
-
txtBox.Text = dr1(i)
-
cnt = cnt + (txtBox.Height + 15)
-
End While
-
cnt1 = cnt1 + (labl.Height + 15)
-
End While
-
End If
-
-
Catch ex As OleDbException
-
-
MessageBox.Show(ex.ToString())
-
-
End Try
-
If cn.State <> ConnectionState.Closed Then
-
cn.Close()
-
End If
-
If cn1.State <> ConnectionState.Closed Then
-
cn1.Close()
-
End If
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Andrea M. Segovia |
last post by:
Hello,
I am a newbie to Oracle databases....
We have a visualization front-end tool connected to an Oracle back-end
database on a Tru64 UNIX server. We also have clients with MS access
databases who would like to share their data using this visualization
tool but do not want to import their data into the Oracle server
back-end.
|
by: Mike Turco |
last post by:
(This was also posted to comp.database.ms-access before I realized this was
the hep group.)
Lets say that my WinXP computer has two users: Michael and Kathryn. One or
the other logs into the computer and opens up an Access database (I happen
to be using 2002). There is no security on the database -- just click on the
shortcut and you're in.
I want to be able to determine who opened that database by knowing who
logged into the computer.
|
by: Tom Weston |
last post by:
Help
I have 4 databases containing different data relating to safety, not written
by me. It is not possible to merge the databases into one large data base. I
would like to create a user interface with 4 buttons, one for each database.
The aim would be for the user to click on a button and the related database
opens for use. When the database is closed the user interface with the
buttons on returns. Can anybody offer a method of achieving...
|
by: Kelly |
last post by:
Hi Everyone
I have a web application and all it basically does is ask for a user
id and show a questionnaire. To create the questionnaire, I get the
list of questions from the database and dynamically add controls
(i.e,. labels, radiobuttons, textboxes) for each question. If the user
has visited the page before, I will go to the database and populate
the questionnaire with the answers that the user have entered before
and display it to...
|
by: Slam via DotNetMonster.com |
last post by:
I want to create a couple of dynamic controls and the controls definitions
are stored in a database. Once the the controls are created, I want to
fill any dropdownlist with database values. And when a user selects or
enter inputs from the dynamic controls those values will then be inserted
into a database in comma delimited format. Then, when that user returns to
view their selections I need those controls (textbox, dropdownlist, etc.)...
| |
by: pbb |
last post by:
I have a web page on which I dynamically create controls based on the
selection a user makes from a dropdownlist (this ddl is not dynamic).
Depending on the user's selection, the controls could be any combination of
textboxes, ddls, popup calendars, etc. The properties of the dynamic
controls are stored in a SQL database so that my program can know what type
of control to render and what items to put in the ddl etc.
My problem is that I...
|
by: Tim |
last post by:
Hello All,
Hope someone can point me in the right direction here.
I have a ASPX page that is being created dynamically. My function adds
Labels and Text Boxes to a Table ready for the user to fill them in.
Once the user has entered their information I need to be able to store it
all in a database. The only problem I have is that by using a Web Button
all the dynamically created controls disapear beacuse of the postback. My
|
by: Hugh Welford |
last post by:
hi
Running an asp site on win/IIs/MSACCESS with a database reaching 45 meg.
Responses seem a little slow. Could anyone provide a checklist of things to
look at to optimise data access on this platform, or point me in the right
direction where I can read up on the subject.
Thanks
Hugh
|
by: srig |
last post by:
hi all,
i hav created a webpart for inserting a record in asp.net ,c# and deploy it in sharepoint.. my code is executing properly.. when i deploy it it asks for insert new record and wen i get the details and click insert the values are not getting stored in sql server database.. could any one point me out what s wrong in the program..i hav posted my prog below
Thanks
Sri
using System;
using System.Web.UI;
using...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |