|
I have set up a typed dataset with 2 tables and a relationship between the 2. For some reason I cannot get the child table to populate.
Here is my code:
Dim ds As New dsEmail
Dim emailHeaderTable As New dsEmail.EmailHeaderDataTable
Dim emailToAdressesTable As New dsEmail.EmailToAddressesDataTable
Dim emailHeaderAdapter As New dsEmailTableAdapters.EmailHeaderTableAdapter
Dim EmailToAddressesTableAdapter As New dsEmailTableAdapters.EmailToAddressesTableAdapter
emailHeaderTable = emailHeaderAdapter.GetData
emailToAdressesTable = EmailToAddressesTableAdapter.GetData
ds.Tables.Add(emailHeaderTable)
ds.Tables.Add(emailToAdressesTable)
For Each emailHeaderRow As dsEmail.EmailHeaderRow In emailHeaderTable.Rows
Dim emailToAddressRow() As dsEmail.EmailToAddressesRow = emailHeaderRow.GetEmailToAddressesRows
For Each toRow As dsEmail.EmailToAddressesRow In emailToAddressRow
MsgBox(toRow.ToAddress)
Next
Next
It appears that the relationship is not there despite it existing in design view of the dataset.
What am I doing wrong?
|
|
|
|
|
Hi,
Im having trouble populating my datagrid control from an ms access database. 1st method I used was through ADODC control and it worked fine. Then I just found a way to lessen the code by creating a class then passing variables through a module. Anyways using the class method my datagrid does not show any data at all. I've removed the datasource control and debugged the program...record count shows that it did get something. Im just in the dark why it won't populate in my datagrid. By the way I'm using vb6 and datagrid through common control 6.0.
populate datagrid
clsPubConnection.GetQuery rs1, "insert query here", 1, 1
Set dgd1.DataSource = rs1
dgd1.Refresh
code inside the class
If rs.State = 1 Then rs.Close
With rs
.CursorType = intCursorType
.LockType = intLockType
.ActiveConnection = cn
.Source = strSqlCommand
.Open
End With
Any help would be greatly appreciated. Thanks in advance
Aim small, miss small
|
|
|
|
|
Hi friends,
I am just thinking how can i capture the full height of a window that has an scroll bar?
pls give me your sptep by step ideas.
tx
|
|
|
|
|
You would have to find the height of the window and then account for both the visible, and invisible parts of the scrollable area.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hai expert cumming.
Thank you for the reply.
"You would have to find the height of the window"
Height of the window using GetWindowRect() is normally returned only the visible area if i am corect?
so how can i retrive the full height of the window?
|
|
|
|
|
Dear All,
Sorry this is a newbie type question though er, I have been programming for er 10 years.
I have found one or 2 C++ pieces of code to enable squiggly lines under a text box. Alas I am no good at C++ anymore and am a VB er person. I find references to an Extended Rich Text control, but I have seen in other applications without rich text control. Unless that is just appearance.
What would be the recommended path for me to try, I can use a rich text box, but ultimately I would like to have a textbox which has a spell check with some other thesauras type feature (it is for a recruitment project and I would like to have words that move people into categories - eg: if it finds FMCG underlines in blue and if the use right clicks it says it is part of Sales, Marketing and Advertising.)
Many thanks
|
|
|
|
|
jinxster wrote: squiggly lines
Not sure what this means.
As far as spell check is concerned, there is some help here[^] and here[^].
In case you are using .Net Framework 3.5, there is a SpellCheck class which might help you.
|
|
|
|
|
He means the lines that show up in say Microsoft Word when you spell something wrong.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
OK. First help link I have posted does that. But not the lines, it changes the font color to red. I dont know if we can change color change to squiggly lines.
|
|
|
|
|
You can with a custom drawing routine, or the link I posted did it with WPF. I've seen it done before, but can't find it now.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
|
Can some one help
Listbox1 is Data A,B,C,D,E from the SQL base . Id automatically increases every day after entering new values for A,B,C,D,E while Id is date
Every day I want to compare data of the last day with the past 4 day’s data and get values of P1, P2, P3, P4.
Listbox1 =Data from base
Id A B C D E
15 2 4 6 7 8
14 2 6 8 7 2
13 1 4 1 5 8
12 3 3 3 7 2
11 5 6 8 4 1
10 5 8 7 7 7
09 4 4 7 7 7
08 1 2 6 5 4
07 1 5 8 9 5
06 6 6 3 3 2
05 2 2 5 7 8
04 4 7 5 2 3
03 4 6 8 4 9
02 2 2 4 4 7
01 5 7 5 6 1
Listbox2 = Expected results with VB codes
Id P1 P2 P3 P4
15 2 2 1 0
14 0 2 2 0
13 0 0 0 1
12 0 1 1 1
11 1 0 0 1
10 3 0 0 0
09 0 0 0 1
08 1 0 2 0
07 0 0 0 1
06 0 0 1 0
05 1 0 2 1
04 1 0 2 -
03 1 0 - -
02 0 - - -
01 - - - -
The problem is that I want through VB codes to add these values to be added to listbox2
Here P1 at Id 15 = 2 is the value got counting when
Data A at Id 15 = data A at Id = 14 +
Data B at Id 15 = data B at Id = 14 +
Data C at Id 15 = data C at Id = 14 +
Data D at Id 15 = data D at Id = 14 +
Data E at Id 15 = data D at Id = 14 (P1 = 2 Data A & D)
Here P2= 2 is the value got counting when
Data A at Id 15 = data A at Id = 13 +
Data B at Id 15 = data B at Id = 13 +
Data C at Id 15 = data C at Id = 13 +
Data D at Id 15 = data D at Id = 13 +
Data E at Id 15 = data D at Id = 13 (P2 = 2 Data B & E)
Here P3= 1 is the value got counting when
Data A at Id 15 = data A at Id = 12 +
Data B at Id 15 = data B at Id = 12 +
Data C at Id 15 = data C at Id = 12 +
Data D at Id 15 = data D at Id = 12 +
Data E at Id 15 = data D at Id = 12 (P3 = 1 Data D)
Here P4= 0 is the value got counting when
Data A at Id 15 = data A at Id = 11 +
Data B at Id 15 = data B at Id = 11 +
Data C at Id 15 = data C at Id = 11 +
Data D at Id 15 = data D at Id = 11 +
Data E at Id 15 = data D at Id = 11 (P4 = 0 Data)
Etc….etc
Even the user wants to compare up to the past 15 data so that I have up to P15
|
|
|
|
|
What version of visual basic are you using VB6, VB.net or another?
The code will be slightly different in the way you access the listbox depending on the version.
|
|
|
|
|
Thanks for your reply
Iam using MS VB 2008 EXPRESS EDITION
jaakinye
|
|
|
|
|
Re: Compare data of the last day with the past 4 day’s
I use VB 2008 EXPRESS EDITION
I dont have formular as you can see from this
that is why I need VB eihter throuh array or index to get this
Id A B C D E
15 2 4 6 7 8
14 2 6 8 7 2
for example as above,data A in day 15 repeats its value of day 14 and data D in da 15 also repeats its value of day 14. These are 2 data that repeat their values of day 14.Data A and D are 2 data therefore P1 = 2.
Id A B C D E
15 2 4 6 7 8
13 1 4 1 5 8
The same thing above
P2 (day 15 compared with day 13. Data B in day 15 repeats its value of day 13 and data E at day 15 also repeats its value of day 13.This gives 2 data and therefore P2 = 2
Id A B C D E
15 2 4 6 7 8
12 3 3 3 7 2
As above only 1 data (D) at day 15 repeats its value on day 12.Therefore P3 = 1
Id A B C D E
15 2 4 6 7 8
11 5 6 8 4 1
as above no data at day 15 repeats its value at day 11.Therefore
P4 = 0. Day 15 is the last data and is compared with day 14,13,12and 11.The next day will be day 16 and it will be copared with days 15,14,13and 12 while day 17 will be compared with days 16,15,14 and 13 etc.
How do I use codes to get these?
Thanks for your help
|
|
|
|
|
I assume that your are quite new to VB.net but I may be wrong. I have therfore written the attached code using an array as you asked. I would not say it is the best method but if you are learning they I thought it better.
Create a new project with a form1 and two listboxes (ListBox1 and ListBox2)
Replace the code from your form with the attached code.
It automatically generates test data to show you it working.
It may not be exactly what you want but its a start.
Public Class Form1
Const NumberOfDaystocountBack = 4 'This is a constant for the number of dats you will count back
Dim OriginalDataArray(15, 5) As String 'This is a sample array with 15 records each with 5 pieces of data
Dim ResultsArray(1, 1) As String 'This is a sample array that will store the data, it is resized with the code
Private Sub Main()
'Generate test data
Dim X As Integer
Dim Y As Integer
Dim TempString As String
For X = 15 To 0 Step -1
TempString = ""
For Y = 0 To 4
OriginalDataArray(X, Y) = Int(Rnd() * 10)
TempString = TempString & OriginalDataArray(X, Y).ToString & ", "
Next
ListBox1.Items.Add(TempString)
Next
GenerateResults()
For X = 15 To 0 Step -1
TempString = ""
For Y = 0 To 3
TempString = TempString & ResultsArray(X, Y).ToString & ", "
Next
ListBox2.Items.Add(TempString)
Next
End Sub
Private Sub GenerateResults()
Dim MaxDayCount As Long
Dim LoopCounter As Integer
Dim RecordLoopCounter As Long
Dim DataLoopCounter As Long
Dim DataCount As Integer 'count of the number of data elements
Dim TempArray1() As Integer
Dim TempArray2() As Integer
DataCount = OriginalDataArray.GetUpperBound(1) 'This will be '5' for the sample array given
MaxDayCount = OriginalDataArray.GetUpperBound(0) 'This would be 50 for the sample array given
ReDim ResultsArray(MaxDayCount, NumberOfDaystocountBack) 'Resize the results array to accept data
For RecordLoopCounter = MaxDayCount To 0 Step -1 'Steps back through records of data
'Pass the two days data to the comparison function
For DataLoopCounter = 1 To NumberOfDaystocountBack
ReDim TempArray1(DataCount) 'Resize array to the number of data elements and clears data
ReDim TempArray2(DataCount) 'Resize array to the number of data elements and clears data
If RecordLoopCounter - DataLoopCounter >= 0 Then
For LoopCounter = 0 To DataCount - 1
'Creates two temporary arrays that hold the data for the two days in question
TempArray1(LoopCounter) = OriginalDataArray(RecordLoopCounter, LoopCounter)
TempArray2(LoopCounter) = OriginalDataArray(RecordLoopCounter - DataLoopCounter, LoopCounter)
Next
ResultsArray(RecordLoopCounter, DataLoopCounter - 1) = CompareTwoDays(TempArray1, TempArray2)
Else
ResultsArray(RecordLoopCounter, DataLoopCounter - 1) = "-"
End If
Next
Next
End Sub
Private Function CompareTwoDays(ByVal TodayArray() As Integer, ByVal CompareDayArray() As Integer) As Integer
Dim TodayArraySize As Integer
Dim LoopCounter As Integer
Dim TempCount As Integer
If TodayArray.GetUpperBound(0) <> CompareDayArray.GetUpperBound(0) Then
'Put your error handling here
MsgBox("Cannot compare arrays of different sizes.", MsgBoxStyle.Critical, "Error")
End
End If
TodayArraySize = TodayArray.GetUpperBound(0)
'Loop through array to compare values
For LoopCounter = 0 To TodayArraySize - 1
If TodayArray(LoopCounter) = CompareDayArray(LoopCounter) Then TempCount = TempCount + 1 'or you can use TempCount+=
Next
Return TempCount
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Main()
End Sub
End Class
Good luck
|
|
|
|
|
Hello everybody,
during my first steps with VB2008 I've been facing quite a few challenges... and here I am asking for your support again...
One of my forms holds a "New Folder" button, which simply opens an InputBox to let the user set the new folders name. But if the user doesn't enter any text (or clicks the inputboxes "cancel" button), the underlying form acts as if its own cancel-button had been clicked - it receives the "form_closed" event and closes, too. All I want is to close the inputbox only and leave the major form open!
How can I change this behaviour?
Thanks for any hints
Michael
|
|
|
|
|
Show us the relevant code (using the "code block" button!) so people can help you.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Here it is, containing some dummy stuff. The three routines are part of "frmFolderBrowser", which is basically a form using a tree view control to simulate the windows explorer:
When clicking the "New Folder" button, the InputBox shows:
Private Sub btnNewFolder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNewFolder.Click
If Not SelectedPath Is Nothing Then
Dim NewPath As String = InputBox("New Folder:", "Create Folder")
If NewPath <> "" Then
'Dummy
MsgBox(String.Format("Folder {0} has been created", NewPath))
End If
Else
MsgBox("A path has to be marked!", MsgBoxStyle.Exclamation, "Error")
End If
End Sub
An empty InputBox (OR its cancel button) not only closes the InputBox but also frmFolderBrowser. Maybe there's some mess coming up from "frmFolderBrowser" having its own Cancel-Button, of course:
Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
DlgResult = False
Me.Close() 'supposed to close frmFolderBrowser
End Sub
Clicking the Cancel-Button of the InputBox seems to trigger the Cancel-Button of frmFolderBrowser, too... which I can follow in step mode:
Private Sub frmFolderBrowser_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
frmCenter.Refresh()
End Sub
Hope I could make it any clearer...
|
|
|
|
|
Hi Michael,
I ran a test containing your code, and it behaves the way it should, i.e. whatever way the InputBox gets closed (OK, Cancel, CloseBox) the form remains alive.
I googled a bit but came up empty handed, your problem is not a popular one.
Furthermore I cannot imagine a way to achieve the symptoms you describe, since InputBox is a very simple and completely closed Form, one cannot manipulate the way it behaves or tell it to manipulate anything outside itself.
Is there anything really special you did? wild guesses: installing a native hook, handling your own wndproc or message pump, ...
If you create a new Windows project, single form, and give it basically the above code, does it still go wrong?
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi Luc,
thank you for taking the time! And in my beginner's shoes there's nothing like native hooks hidden - or anything of the other tricky stuff you guessed. But it's even good to know that InputBox is a closed form and that it SHOULD behave different even the way I coded it.
I'll follow your advice when I find the time again, try the code in a new project and see if I can find the root of evil in this little bastard
Thank you again!
Michael
|
|
|
|
|
You're welcome.
And good luck with it.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Michael Schäuble wrote: How can I change this behaviour?
I'm wondering what you did to CAUSE that behavior! That is not normal and I suspect something in your code is not written correctly to cause something like this to happen.
|
|
|
|
|
Hi Dave, I'm afraid you're right but have no clue WHAT exactly I did wrong. Just posted some code hoping to show what I did ... maybe you have some minutes for examining? Thank you in advance!
|
|
|
|
|
I have written a tcp server to handle requests, most of which access a database for some sort of information. My question is how do I structure the error handling. Some errors I want to propagate up to the user level and others I want to just handle where they are. For example. If the database in unreachable - I want to wait and then try again but if there is a problem with the retrieved data, I want to send it up to the calling code so I can Send a tcp message back to the client. I am not sure if I should be putting try catches in all my routines (which i dont think is right) or just in specific spots. I am just having trouble figuring out the correct way to do this.
Does anyone know of some good error handling tutorials I could take a look at?? Thank You
modified on Thursday, March 12, 2009 7:38 AM
|
|
|
|