Open a VFP Database Container with OpenData event coded - vba

I am migrating data from a Visual FoxPro Data Base Container to Excel using VBA.
After trying and failing various settings of the Connection String in order to open the Container, I discovered that at Container was placed code at OpenData event; this code asks a password to open the Container. This prevents other programs open the Container for access to data, including the Password parameter of the Connection String.
Are there a way to open the Data Base Container with OpenData coded event? If the answer can be implemented in VBA, please let me know how I can do it.
Thanks for your attention.
PD: Forgive my english. Is not so good.

Solution details would probably depend on what the (custom) "Stored Procedure" code in the Vfp database is doing exactly, where one way could be simply removing it. If you got a Visual FoxPro IDE, you could for example do so by using the IDE's "Command Window":
MODIFY DATABASE ?
and then right-click the Database Designer window, choose the desired "Event" in the Properties dialog -> "Edit Code".
If then for example the code would simplified look like
PROCEDURE dbc_BeforeOpenTable(cTableName)
*Just before a table or view is opened. Return .F. to prevent table or view being opened.
RETURN INPUTBOX("Password") == "Test"
ENDPROC
... you could simply
RETURN .T.
instead

Related

How to Open VB.NET Form in Design Mode

I have a VB.NET solution created in Visual Studio 2017. It seems like I used to double click Form1.vb in the Solution Explorer to open the form in design mode so I could add buttons and such.
Now no matter what I do, I can't open the design form window. It seems like there are fewer elements in the Solution Explorer, but I'm not sure:
Can someone tell me how to open the Form Designer again? Thanks.
The issue is exactly as I described in the first comment. Only the first type in a code file can be designed. If ServerForm is declared after ClientClass then ServerForm is not the first type in the code file, thus it cannot be designed. You could move ClientClass after ServerForm and that would address the issue but I would suggest doing what you should have done in the first place and declaring ClientClass in its own code file.
To that end, select the entire ClientClass definition and cut it to the Clipboard. Right-click your project in the Solution Explore and select Add > New Class and name it ClientClass, then select all the code in the new file and paste what you previously cut. You should then be able to build your project and now open your form in the designer.
I have two further suggestions. As I said, you appear to have renamed your form in the code. Don't do that. You now have the class name and file name out of sync. If you want to rename a type then you should also rename the file it is declared in. As you should almost always have just one type per file, they should be named the same. If you right-click the item in the Solution Explorer and select Rename, you can rename the file and you will then be prompted to similarly rename the type, which you should accept.
Finally, you should pretty much NEVER use "Class" as a suffix on the name of a class. You'll note that the String type is not named StringClass. You really ought to rename your ClientClass type Client. You might want to elaborate on what type of client, but the "Class" suffix is not a good idea.

How to find a form from many forms in vb6 on a existing project

I am working on a old project of vb6 which has hundreds if forms. I am able to run the application and have to fix a runtime error in a form which pop up. I don't know the name of the form and only have visual reference. I tried using debug but It has continues SQL statements running in a loop. Any advice is appreciated.
Thanks.
Search the code for the form caption, or the labels of controls on the form, using visual studio's "find in files" or simlar function of your favourite editor.
If the caption is set in the form design, this will take you to the .frm file the form is stored in. You can open this in Notepad or another editor to get the name of the class (which is usually the same as the filename).
If the caption is set in code, you can place a breakpoint on that line. Again, this will lead you to the code which instantiates the form.

How Does Visual Studio/VB Create and Initialize a Table Adapter?

I have a very simple Windows form application that uses a data set. I am having trouble figuring out how Visual Studio creates a new Table Adapter object and then initializes that object through its insertion of initialization code into the .Designer.vb files. My problem is I have inadvertently caused this to happen through some series of commands I do not remember, and am trying to figure out how to re-create what I did.
For example, if I want the data set to be used by a form, I know this goes in the form's Designer.vb module
Friend WithEvents StreetsTableAdapter1 As WindowsApplication1.DataSet1TableAdapters.streetsTableAdapter
However, this line alone won't instantiate the table adapter object.
As to the data set, I've created a one; configured one of its table's table adapters to use SQL queries; tested those queries; and they work.
I'm more interested in what Visual Studio writes to create the new object rather than the keystrokes to do it, because I'd like to know what's going on underneath the covers, rather than relying on keystroke magic.
I have a workaround
Me.StreetsTableAdapter1 = New DataSet1TableAdapters.streetsTableAdapter
I've added this to the form's .Designer.vb file. I'm still trying to figure out what I did in Visual Studio to get all this initialized through running some specific commands.
A pointer to an example would help, as well as the steps to make this happen. Then, I'll examine what Visual Studio does, so I do not get stuck again.
The easiest way to create the table adapter on your form is to let Visual Studio do it for you. In the toolbox "DataSources", you should see your current data. You can expand the nodes and drag the fields/tables to your form. This will create the table adapter and everything needed behind the scenes.

Changing form name causes error message "Error accessing the system registry"

I am programming the On_Click method for the button labeled "View" in the first printscreen below. The method will load a form with data corresponding with the specific address id in the row containing the "View" button. This code worked perfectly when pointing to a target form called "Addresses". However, when I decided to rename the form "Address", I started receiving the following error message when clicking on the view button:
I did some research on the web about this error message, which lead me to try to delete any outdated references in the VBA editor. But when I clicked on Tools-->References in the VBA editor, I got the following error message:
It seems that MS Access' entries in the system registry might have been corrupted. But I am not certain of this because the documentation of this on the web is sparse and inconsistent.
Here is a link to the database on a file sharing site: http://jmp.sh/b/9Uyx6J2YzWbs8zPq2h6g
If the problem is in the database, you can recreate the problem by opening the form "Main" and clicking on the button "View" for the record shown in the printscreen above, or for other records.
Can anyone show me how to get past this error message?
my advices?
You could rename your Forms!....SourceObject to "Address" instead of "Addresses"
You could copy/paste the form, delete the original, and retry
You could install a decent debugging tool like MZ-Tools for VBA, that will help you manage your errors. Check the details here
EDIT: I used to get similar bugs years ago, when I was writing specific form event procedures. As we decided to switch to a model where forms did not need to be debbuged anymore (check this here), we stopped getting this kind of message. And I think I forgot the trick we used to solve this kind of error. If I were you:
I'd try to open another access database and import all objects ...
I'd put aside/cancel the faulty onClick procedure
And I'd install MZ Tools because otherwise VBA debugging is a nightmare ...
Since access was not liking the command button in each record of the continuous form, I choose to put the view button's logic in the on click event of a text box in each row, which I configured as enabled but locked. This produces a separate link from each record of the continuous form to a unique detail page with more of the chosen record's data.
This solution works perfectly, and is enabling me to move on with my other coding.
However, it would be nice if someone else were able to show how to get the command button solution to work.

RDLC Report Data doesn't update to reflect changes

On my RDLC page, the "Report Data" window shows a custom dataset that it pulls fields from to display. I've modified this DataSet with some additional tables. However, these tables aren't shown and therefore I'm unable to select them for use in expressions (in the Expression window, under Datasets, there are only the tables that were originally there, not the additional tables I've added).
Refreshing the data source doesn't do anything, and if I right-click on it and select "New Dataset", I'm unable to select the parent data source (it doesn't appear in the drop down list). What I mean is, if the data source is called "MyDataSet", and under that are other DataSets, if I right-click and go to "Add Dataset", it brings up the dialog box but "MyDataSet" is not in the list of available Data sources, even though I'm specifically saying I want to add a datatable to that data source. The other, existing, datatables list it under the data source, but new ones do not.
How do I refresh the data source so I can access these new tables in my report?
This is an old question, but I was having this problem too and I'll mention my answer for future googlers.
In the Report Data Window (which automatically appears for me when I am editing a .rdlc file), I had to Refresh my Dataset (same name as the DataSetName in the Tablix in my .rdlc Report), and then that updated the XML of the .rdlc file. The new fields are then available to me.
I have the same problem with Visual Studio 2010 Premium. You must do this step:
Re-build the project that contain your Business Object
Restart Visual Studio
Refresh your DataSet (Report Data --> Right click on DataSet --> Refresh).
I managed to get this working (for SSRS in C# using a Dataset that points to a Stored Procedure) by:
hitting Shift+Alt+D (which opens the "Data Sources" window)
In Data Sources, select/click the table you want to update
At the top of the window there are icons (I'm using VS2012). The 2nd from the right is "Configure Data Source" - click it and it will open a new wizard window that will appear to be refreshing everything.
UN-check the column that is no longer applicable and/or check the new column (if the values aren't already checked/unchecked).
Go back to your "Report Data" window (Ctrl+Alt+D) and right-click on your Dataset and then click "Refresh".
All the columns should be updated at that point.
Have you tried rebuilding your project? I had to do this after changing any business object.
I had this issue for hours on VS-2008. Tried everything and at the end what worked was just to close and open it VS again.
I can confirm that just closing the solution and reopening it, with later refreshing the DataSet from Report Data window worked for me.
Seems like there is no need to restart VS.
I got the same issue in visual studio 2012. I solved it, here is the steps,
Press Ctrl + Q and type Report Data (If No Report Data window available)
Expand Data Source node to find the data set (I have used Data Set)
Right click on the Data set and select Refresh (Simply refresh the data source)
Delete the dataset and again add it with ur query or usp...
If you are using a database source the likely culprit is that you didn't create the query with select *. Without the * the query will always be static and new fields won't appear. HTH
For visual studio 2010
Open Your Data Set (.xsd file)
Right click on data set click on configure
Click on Next Next than finish
On your dataset click refresh than Changes willbe display.
Sounds like same issue is happening on VS2019. I could resolve the issue by only restarting Visual Studio, nothing else worked!
This is the only solution worked for me.
After updating the DataSource properly, open the .rdlc file in NotePad and add the newly added Field manually. Then it will be available to use in the report.
Had the same in VS2019 using an object datasource, right click and refresh on the dataset in the Report Data window had no effect until I changed the build configuration from x64 to Any CPU, then it worked as expected. Once it updated changed the build back and all was well - not at all flakey!
As ChanthJ said -
It is the only solution worked for me.
After updating the DataSource properly, open the .rdlc file in NotePad and add the newly added Field manually. Then it will be available to use in the report.
steps
Assuming you Data source is fed by stored procedures, the following worked for me (On Visual Studio 2017): -
Make the necessary changes in the source stored procedure in the Database(new Field Names etc.).
Double click the .XSD file from the Solution Explorer to open it
Delete the associated Data Table / Table Adapter.
Add the Table Adapter back into the .XSD file (the changes will be reflected)
Save and close the .XSD
Open the .rdlc report designer.
Press "ctrl+Alt+D" or Click View > Report Data.
Expand the Data Sources node.
Right Click the Data Source.
Select "Refresh".
Expand the Datasets node.
Right Click the Data Source.
Select "Refresh"
The changes will now reflect and be available for selection on the .rdlc
report designer