PowerBuilder 12.5 tutorials - sql

I am new to PowerBuilder Classic 12.5. I have created ado.net database profile. How can I now connect to it and create a login window to read username and password, validate and let the user access to the program.
Please help with a sample code and where do I put the codes?
Thanks.

Making the database connection was one of the things that took me the longest to learn, not because it's difficult, but because you do it once and don't have to look at it again.
In your code, you'll need to set the properties of the SQLCA global transaction object. If you have the connection defined in your database painter, then you can right-click on it, choose "Properties", and see what the syntax needs to be from the "Preview" tab.
This syntax will (probably) include your security credentials for the connection. You'll need to build your own userid/password prompt and parse the results into the connection string. I don't have ADO.NET installed, but here's a sample of an ODBC connection... straight copy and paste:
// Profile CINEMA3
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "ConnectString='DSN=cinema;UID=UserName;PWD=SuperSecurePassword'"

Related

How to fix "login failed for user" when manipulating SQL database in Azure from a .NET Core webapp?

I have an SQL Database in Azure and a .Net Core web app in which I would like to manipulate the database using Entity Framework Core.
I believe I have all the model, data and controller classes needed for this, and I have a few sample objects I'd like to see in my database.
My problem is that no matter what I do or how I want to manipulate the database, I always get the error "login failed for user", yet the login info is an admin and I believe I set up everything that is needed.
I see the database in the SQL Server Object Explorer, I can connect to it using SSMS or simply on the Azure Portal, and there seems to be no problem with my connection string. The username&password combo is fine, I've checked it multiple times, my IP is enabled in the firewall of the database, I have no idea what could be the problem, please help me!
Here is the error:
The problem is solved now, it was a very tiny, stupid error:
the connection string I copied from the Azure site was waiting for an escaped field, assuming I won't write my username and password manually, which of course won't be happening in the future, I just wanted to test if the whole stuff worked as this is my first project in this area.
So the Azure connection string looked like this: USER={XY};PASSWORD={ASD} but I left the curly brackets in the string even though I didn't use a variable there.
I test and it works fine. So I am doubt about whether you could run it in local with the connectionstring of Azure sql database.
Open your azure sql server on portal and click your sql database.
Click the Connection string and copy the connectionstring. Filled into your username and password.
Then put it to the connection string in appsettings.json on visual studio.
If you could run on local, then you publish will have no problem.
Also, you could follow this article to learn with asp.net core mvc.

Cannot make a connection to a SQL Server data provider using the Entity Data Model Wizard

Ok, I never got the this error before...
Unable to find the requested .net framework data provider. it may not be installed.
I'm simply trying to connect to a good old MS SQL Server and I get the above error.
The project is just a Class Library with just a Properties and References folder. I added an app.config file to it.
Here are my steps for my project:
Add New Item
ADO.Net Entity Data Model
EF Designer from database
New Connection...
Data source: Microsoft SQL Server (the Data provider then shows up as: .Net Framework Data
Provider for SQL Server
Continue
Right here, if I click "Test Connection" without any info entered about the server, I get "Test Connection succeeded". I don't know why...
Enter the Server name
Enter the userid and password for SQL Server Authentication
When I select "Select or enter a database name", it tries to load a database list, but it immediately goes blank. I even try typing in the database name
Hit OK
That's when I get the error.
Can someone please tell me what I need to do to resolve this?
Solution solved at this link with the msg posted by Barrett.
http://social.msdn.microsoft.com/Forums/en-US/7b4f353b-77fd-427c-976b-5968abc88c13/visual-studio-2010-unable-to-find-the-requested-net-framework-data-provider-for-sql?forum=vseditor
I hope this helps anybody else out....

Access ODBC Issue: ODBC--Call failed

I created an Access front end for a SQL DB on my PC for use throughout my company. I am using a file ODBC connection and putting both the ODBC file and the Access file on a shared network drive.
When I load the access file, for some reason it seems to default to using my windows login credentials and pulls in the data perfectly. When a user attempts to open the file, they receive an error message saying "ODBC --call failed.". I can open the Linked Table Manager for them and check 'ask for new location' then specify the ODBC file and it all works fine...however it doesn't seem to save anything. I get the error each time someone other then myself opens this file.
Any idea what could be wrong? I am not an Access guy by trade, it just seems to be the tool we need for the moment.
--EDIT: For Clarification I am using a file ODBC connection
--Edit 2--
Riddle me this. So I have been troubleshooting this issue and I came across something interesting. I was logged in as one of my users and did the following:
Create a new access file that references a file ODBC connection on the desktop.
Create 3-4 linked tables in the access file, using the ODBC file on the desktop.
Save and close the access file.
Re-Open said file.... and I get an ODBC connection error! Right after everything was fine in a fresh file!
Anyone ever experience this?
i assume you didn't install the ODBC correctly on each users PC.
you should create the ODBC-definition. You can create the relevant statements directly in the registry, see this branch
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI
if you give the same name as on your developer machine, then it works. that's how i do it with my client applications that i develop on my machine and then install it at client site
After beating my head against the wall having this same issue, I finally discovered I had a checkbox on the Access form that defaulted to NULL. Since I put the backend into SQL, the checkbox fields cannot be NULL but the 'ODBC Call Failed' message did not help. I finally tried to add a record directly on the table via Access and it gave more information. I set all the checkboxes to default to zero and it resolved the problem!
Well, I was able to narrow the issue a bit. Access for some reason keeps trying to use Windows Credentials instead of the username in my ODBC file. I can't find a way around it, but I was able to resolve the issue by creating logins on my SQL Server for the windows users that need access.
I am not incredibly happy about needing to manage more logins, but that's what i did to resolve this issue.
I don't mean to resurrect the dead, but I had this same error stem from a different issue.
I was using an ODBC connection. When running the file using the 'Design' run button it worked fine. When I tried using the Navigation Pane and double clicking on it, the error would happen.
The structure of my query was the problem; I was porting a SQL server query over and the single quote ' parameter passing was not well received in Access. Changing these over to double quotes " made it work.

How do I connect to a database in LabView

I've created a new database using Microsoft SQL Server Management Studio, and now I want to interact with it through LabVIEW. I already have several VIs to interact with a previous database, using the database connectivity tool kit. This database was created by someone who has since left the project and I can't find it in anything but LabVIEW.
I'm quite experienced with LabVIEW, but completely new to and bewildered by databases.
Thank you in advance.
The first Connectivity Toolkit VI called should be Open Connection.
The existing code (VI) will either use a file or a string as an input.
If the input is a string, then you will need to create a new connection string compatible with your server. You can find common SQL Server strings at https://www.connectionstrings.com/sql-server-2008/
If the input is a file name, you can copy the .UDL file that is referenced and then modify the copied file by opening it (double click) and then select the OLE DB Provider for SQL Server and then set the connection options to point to your server, database etc. and then test the connection.
Basically the workflow you have to go through is the following:
Open connection
Execute your query
Fetch data (if needed)
Close connection
If you search for "Database" in the NI Example Finder shipped with Labview you will find a few good starting points.
In particular give a look to Database Connection.vi and Database Fetching.vi.
If you plan to use transactions try also Database Transaction.vi.
I found that the solution to my problem was to create a .udl file and use that as the file path for opening the database connection.
Here's the address that taught me how to do this:
http://msdn.microsoft.com/en-us/library/e38h511e(v=vs.71).aspx
Thank you to everyone who submitted answers, they certainly helped point me in the right direction.

Access Log in troubles

Lately there has been a problem running some of our reports in access. Last week(the beginning of the week) we tried to run a reports lets call it A and it kept giving us the log in prompt. Even when the correct user-name and password were entered the log in box would just keep reappearing until cancel was pressed.
I clicked the debug and checked the query. I then logged into the database it is pulling the data from with the same user-name and password and received no trouble. Around Wednesday A was working again, even though nothing was changed. This week A is working but another report B is doing the same thing..
Anyone have any idea what this could be? I'm thinking maybe someone else has the report open? Any help is appreciated.
EDIT: I have narrowed down the error to one linked table that is causing the login prompt. It seems it has the DSN setup but no database specified. So i just need to relink the table..Is there anyway to do this at the GUI level? Also should I leave this question up for future users or just delete it?
Was the login prompt from Access or from Windows? If from Windows, then I'd say that there was some sort of file permission or network access issue at hand. If from Access, then I would say that something in the SYSTEM.MDW that you are using is corrupt or has been reconfigured.
If the login prompt is from ODBC it probably means that the credentials that are being used to access the backend database (per your comments you mentioned it was SQL Server) are either invalid or disabled. (Or it could be as simple as the backend database is/was temporarily unavailable).
If you are using linked tables in Access to a SQL Server it means that an ODBC connection was created and you might try verifying that the ODBC connection is working ( Control Panel, Administrative Tools, Data Sources(ODBC) ). In that dialog there is a place to test the connection.