Page 1 of 1
SQL connection
Posted: Wed Jan 31, 2024 1:28 pm
by Jeff Barnes
So this is going to sound very simple to those of you who use sql but I've have never used sql so here goes....
All I need to do is:
-Connect to the SQL server
-Add a new record
-Add the data to the record (2 fields "Name" and "ID")
-Save and close
I've looked at some posts but I see different people doing things different ways and now I'm confused
I should also mention that I've been out of the programming game for a while and am a bit rusty.
Can anyone point me in the right direction?
Re: SQL connection
Posted: Wed Jan 31, 2024 2:12 pm
by Jeff Barnes
Forgot to mention that it's a Microsoft SQL server I need to connect to.
Re: SQL connection
Posted: Wed Jan 31, 2024 3:23 pm
by Otto
Hi, Jeff, nice to see you again. It seems like you haven't been here for a long time.
I've often wondered if you're still working on your program. Unfortunately,
I've shut down all my SQL servers and haven't done anything with them for a long time. But I'm happy to see you.
Best regards,
Otto
Re: SQL connection
Posted: Wed Jan 31, 2024 3:40 pm
by Jeff Barnes
Hi Otto,
Nice to see you again too
I retired back in 2020 but still do a bit of programming here and there.
Glad to see your still going
Re: SQL connection
Posted: Wed Jan 31, 2024 8:28 pm
by nageswaragunupudi
This is our recommendation:
Code: Select all | Expand
function TestMsSql()
local oCn, cSql, oRs
// server // db // user // pwd
oCn := FW_OpenAdoConnection( "MSSQL,208.91.198.196,gnraore3_,fwhmsdemo,fwh@2000#", .t. )
if oCn == nil
? "failed to connect"
else
cSql := "INSERT INTO [STATES] ( [CODE], [NAME] ) VALUES ( 'JB', 'Jeff Barnes' )"
oCn:Execute( cSql )
//
// Now test
oRs := FW_OpenRecordSet( oCn, "SELECT * FROM [STATES]" )
XBROWSER oRs
oRs:Close()
oCn:Close()
endif
return nil
You can test this program from your computer.
This program
connects to a FWH's MsSql server in the cloud. This server is provided for testing by our users.
After testing this, you can use similar logic on your Server.
Re: SQL connection
Posted: Wed Jan 31, 2024 8:49 pm
by Jeff Barnes
Thank you sir. That works when I leave your sample alone.
When I add my connection info, it will not connect.
At least now I know it should work. Not sure why the connection isn't working on my end.
The big issue is me, I just don't know enough about the SQL Server.
Even if I create logins on the server (ie: User=Jeff), It will not let me connect unless I use "Windows Authentication". I think this is where my issue is.
I will keep on trying.
Re: SQL connection
Posted: Sat Feb 03, 2024 1:13 am
by Jeff Barnes
Got it working. It was a setting in MS-SQL. I had to enable both Windows Authentication and SQL user authentication.
Thanks again for the help.