But in that case the If-clause would throw the
exception, wouldn't it?
Yes, it usually would. But it is also possible that the Invoked method is throwing the error and since it does not have a Try Catch block, it is being pushed backed up the stack. Add Try Catch and some custom logging to find out where the problem exactly is.
How to create a Table in a VB6 application. Ihave the following code
Private Sub createDB(dbname As String)
Dim db As Database
Dim td As TableDef
Dim fld As Field
Set db = DBEngine(0).CreateDatabase(dbname, dbLangGeneral)
Set td = db.CreateTableDef("Students_Info")
Set fld = .CreateField("Rollno", dbNumber, 3)
fld.AllowZeroLength = False
fld.Required = True
You already posted this question in Quick Answers.
It's considered a bad habit to post in more than one forum, mainly because readers can't see what answers already have been given (in the other forum).
Please don't do this again.
If you can read this, you don't have Papyrus installed
This is going to hurt, but it's for your own good.
First off all, VB6 is deprecated. It's no longer supperted by Microsoft. It's kicked the bucket, it's shuffled off it's mortal coil, run down the curtain and joined the bleedin' choir invisibile!!
You can use the Microsoft Interop Forms Toolkit[^] to migrate at your own pace. You can extend VB6 applications using .NET code (means you can write new code in .NET and call it from VB6), giving you access to all kinds of .NET goodies like the WebBrowser component, the PropertyGrid control and the EntLib.
Second, you'll need to use something else than a SaaS provider, as they always require internet-access.
Third, you specified what technologies you're interested in, not what you are trying to achieve. You get more usefull replies if you state what you're trying to achieve. Like, if you're looking for longitude and latitude for a specific country, we could advise an alternative like GeoNames[^].
Hi. I am fairly new to VB. I am familiar with reading and writing to a flatfile database in VB and binding it with a datagrid but I have the following problem. I have googled it but couldnt find anything useful. It is a web application.
This was a technical test I had to complete at home in a 2 hour timeframe, for a job application. The 2 hours were from this morning and I already emailed back my attempt. However, I'm still trying to complete the task so that I can learn for future reference as I'm sure I'll encounter relational databases again.
The following are the two tables and their fields:
EMPLOYEE: Payroll (pri key), firstname, surname, department
DEPARTMENT: number (pri key), departmentname, manager
In the EMPLOYEE table, the department is the foreign key to the number in the DEPARTMENT table.
In the DEPARTMENT table, the manager is the foreign key to the payroll in the EMPLOYEE TABLE.
On my form, I have a drop down list which displays the departmentnames from the DEPARTMENT table (these are retail, warehouse and management).
I also have a button and a gridview. When the button is clicked, the gridview should display records from the EMPLOYEE. It should only show the employees who work in the department that was selected in the datagrid. I have the following code at the start of the class:
Dim con As SqlConnection
Dim dsDept AsNew DataSet
Dim dsEmployee AsNew DataSet
Dim daDept As SqlClient.SqlDataAdapter
Dim daEmployee As SqlClient.SqlDataAdapter
Dim sqlDept AsStringDim sqlEmployee AsString
And I have this code on my button:
con = New System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CivicaDB.mdf;Integrated Security=True;User Instance=True")
sqlDept = "SELECT * FROM Department"
daDept = New SqlClient.SqlDataAdapter(sqlDept, con)
Dim currentRow AsInteger
currentRow = 0Dim cmd AsNew SqlCommand
ForEach DataRow In dsDept.Tables("Department").Rows
If dsDept.Tables("Department").Rows(currentRow).Item("Name") = DropDownList1.SelectedValue ThenDim correctDept AsInteger
correctDept = dsDept.Tables("Department").Rows(currentRow).Item("Number")
sqlEmployee = "SELECT * FROM Employee WHERE Department =" & Convert.ToString(correctDept) & ";"
daEmployee = New SqlClient.SqlDataAdapter(sqlEmployee, con)
GridView1.DataSource = dsEmployee
currentRow = currentRow + 1Next
well, if you use VB.NET 2010, then this is the example code to fill binded datagrid.
Private StaffAdapter As New Objects.DataAdapters.StaffAdapter()
Private Sub Staff_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Public Sub LoadData()
Public Sub LoadData(ByVal Id As Long)
If ID <> 0 Then
Me.StaffBindingSource.Position = Me.StaffBindingSource.Find("IdStaff", Id)
and this one is my class
Public Sub FillStaff(ByVal Table As DataTable)
Dim cnn As New SqlConnection([Global].Variables.Config.Connection.String)
Dim cmd As SqlCommand = cnn.CreateCommand()
cmd.CommandText = "select * from Staff"
If cnn IsNot Nothing Then
If cmd IsNot Nothing Then