|
Hi, I'm new here and just recently found this great messageboard. I'm working on a peice of code that requires a program to link to a database with multiple tables in it. I'm trying to link the program to the database and then use a combo box (or some other GUI object) "point" to the different tables in the database but I can't seem to figure it out. Here is the following code I'm using...
Private Sub cmbloadMasterSchedule_click()
dlgcommonDialog.Filter = "Microsoft Access Database Applications(*mdb)"
dlgCommonDialog.ShowOpen
AdoTeamStatsInputUtility.ConnectionString = dlgCommonDialog.InitDir
End Sub
Private Sub ClickEvent()
AdoTeamStatsInputUtility.RecordSource = AdoTeamStatsInputUtility.ConnectionString
cmbListTablesInRecordSet.ItemData (adoTeamStatsInputUtility.RecordSource)
End Sub
I just can't seem to make the combo box display the tables of the Database or allow it to point to a particular Table within the Database. Does anyone have any advice on this?
|
|
|
|
|
Where is the code that builds the combo box?
|
|
|
|
|
Private Sub ClickEvent()
AdoTeamStatsInputUtility.RecordSource = AdoTeamStatsInputUtility.ConnectionString
cmbListTablesInRecordSet.ItemData (adoTeamStatsInputUtility.RecordSource)
End Sub
That is the code that builds the combo box. I know, its not much. That is where the problem is. I'm actually just guessing on how to do it. What I was hoping for is too have the database link with the connection string from the above code, I could use the combo box (with listed tables within the Combo Box) to "Point" to the particular Table I want to input the data.
|
|
|
|
|
|
I'll bet a banana that there is in VB6.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Yes, I'm using Visual Basic 6. Ill look up the "ItemData" object in the MSDN Library. I have some revised code that might be a little clear on this topic. I found out I was using the wrong database object to access the Database. How about this code...
Private Sub cmdLoadMasterSchedule_Click()
dlgCommonDialog.Filter = "Microsoft Access Database Applications(*.mdb)"
dlgCommonDialog.ShowOpen
Data1.Connect = dlgCommonDialog.InitDir
End Sub
Private Sub cmbListTablesInRecordSet_Click()
cmbListTablesInRecordSet.DataSource (Data1.RecordSource)
cmbListTablesInRecordSet.DataField ""
End Sub
I think this new code links to the database, but I'm still stumped on the second code part. I can access the data by clicking on the RecordSource property and choose a particular table to point too, but I still am not sure how to do it with the above code. .DataFeild and .DataSource properties still perplex me.
Any advice here with this new code?
|
|
|
|
|
D. Doulas wrote:
Any advice here with this new code? No, I don't support even the idea of writing anything new in VB6. It is a dead language and there's no good reason to use it.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
With all due respect... but do you mind? This is probably the only message board left I can find tech support for VB.
|
|
|
|
|
D. Doulas wrote: This is probably the only message board left I can find tech support for VB. I don't mind you getting help from others; I do mind the idea of actively writing VB6-code.
..and it's not tech support; its a bunch of volunteers that you are depending on to keep it alive.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Also, a connection-string is not just a filepath.
Login Tutorial Using Access Database - Visual Basic .NET[^]; shows how to connect and read from the datbase.
D. Doulas wrote: Does anyone have any advice on this? Start with any tutorial that shows how to execute a query. Find a query that returns all table-names. Combine both ideas.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Great idea. I look again, but that is what I couldn't find in all my text books. I think the data is being read in the combo box but it just displays a blank combo box with no data.
|
|
|
|
|
D. Doulas wrote: I look again, but that is what I couldn't find in all my text books. "That" is probably referring to the query. Found here[^].
D. Doulas wrote: I think the data is being read in the combo box but it just displays a blank combo box with no data. Why do you think that? Have you tried alternative ways of displaying the data?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
txtPart.Text = mod_ValidateDBFldType(rstOrderID!PART_NUM, rstOrderID.Fields("PART_NUM").Value)
error 1:- field is not a member of the dataset
error 2:- class 'DataSet' cannot be indexed because it has no default property.
after these errors, I changed the code but nothing works.
after changing, I got a null exception error
(1)
txtPart.Text = CType((rstOrderID.Tables("tblOrder").Rows(0)("PART_NUM")), String)
txtOrderQty.Text = CType((rstOrderID.Tables("tblOrder").Rows(0)("ORDER_QTY")), String)
(2)
txtPart.Text = (rstOrderID.Tables("tblOrder").Columns("PART_NUM").ToString)
txtOrderQty.Text = (rstOrderID.Tables("tblOrder").Columns("ORDER_QTY").ToString)
|
|
|
|
|
A DataSet object is totally different to ADODB.Recordset!
To be able to read data from DataSet, you have to refer to DataTable object corresponding to data you fetched from.
Dim dt As DataTable = YourDataSet.DataTables("YourTableName")
For Each r As DataRow in dt.Rows
Next
Dim singleRecord = YourDataSet.DataTables("YourTableName").Rows(0)
txtPart.Text = singleRecord("PART_NUM").Value
Another way to get data from DataSet is to use Linq. See: Queries in LINQ to DataSet | Microsoft Docs
|
|
|
|
|
Thanks for your reply!
I tried what you said but it did not work
|
|
|
|
|
You're not going to be able to do a line-for-line conversion of the code. You're going to have to completely rewrite it in VB.NET, with the understanding of what the goal of the original VB6 code was.
|
|
|
|
|
Just changing it will not work. There are enough tutorials out there that show how to interact with a database. Good luck.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello !
How can I display an image at the center of a form , and this should remain at center even when I resize the form ?
Thank you !
|
|
|
|
|
Without any other info, I would make it a "full" child of the window; with or without zoom.
That'll center it.
|
|
|
|
|
Can you be more clear how can I do that ?
|
|
|
|
|
Seriously?
Open the IDE, open the properties of the form, select a backgroundimage, set BackgroundImageLayout to "center". It's that easy.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Desanti wrote: Yes . I've tried that , but the image is displayed in Top Center of the form , I want that the image to be at center ( horizontally and vertically ). In WinForms, it will center. There's no TopCenter in the ImageLayout Enumeration (System.Windows.Forms)[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello !
I'm using Vb.net 2017.
If for a form , i set the Topmost property to True , this form remain in top of other windows inside its application but also on the top of other program windows.
How can i do that a form to be Topmost only within its application ?
Thank you !
|
|
|
|
|
A MDI (multiple document interface) application perhaps; with one of the "child windows" as top most?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I don't have MDI. Just normal forms
|
|
|
|