Manipulating SQL Database Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Panaku
Posts: 22
Joined: 02 Apr 2022, 17:24

Manipulating SQL Database

02 Apr 2022, 17:53

I'll start by saying I'm just beginning to work SQL Databases. I am trying to use ADOSQL.ahk to manipulate a database I setup. I installed Microsoft SQL Server 2019 and Microsoft SQL Server Management Studio 18, connected using my Window's credentials and created a new Database, Table, some Columns, and some Values. I then added a new Login for the database. I have scoured the forums already and after trying and trying I'm finally reaching out. Below is the code I'm using, and slightly modifying the code I run into a couple different errors but it seems the farthest I can get is the error here.

Code: Select all

#NoEnv
#Include adosql.ahk
#SingleInstance,Force

rs := object()
connection_String := "Provider=MSOLEDBSQL19;Password=snake;Persist Security Info=True;User ID=sa;Initial Catalog=rockinfo;Data Source=<ComputerName>;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Use Encryption for Data=False;Tag with column collation when possible=False"
sql_query := "insert into minerals (Type, Shape) values ('Diamond', 'Princess');"

try
	rs := ADOSQL( connection_string, sql_query ) ;
catch
	MsgBox, Failed
	
MsgBox, Query = %ADOSQL_LastQuery%`nError = %ADOSQL_LastError%
Return
image.png
image.png (7.35 KiB) Viewed 9703 times
I'm stumped, I've tried so many different things I can't figure out where to go from here.
Last edited by Panaku on 03 Apr 2022, 02:20, edited 1 time in total.
Panaku
Posts: 22
Joined: 02 Apr 2022, 17:24

Re: Manipulating SQL Database  Topic is solved

03 Apr 2022, 01:45

I just want to post and update that I finally figured out what was happening. As I expected this almost all boiled down to me not understanding what I was doing with MSSQL Server Management Studio.

I had been connecting to the database in MSSQL using Windows Authentication but had been trying to connect through AHK using SQL Server Authentication. So I tried to connect in MSSQL using the same username and password and ran into the same error which told me it probably wasn't my AHK code that was causing issues. In the end I had connect to first using Windows Authentication, then I had to Right-click my server -> Properties -> Security -> Enable "SQL Server and Windows Authentication mode". After that I was able to connect in MSSQL using the test username and password I setup and so I tried again through AHK and my query fired off perfect on the first try. I do appreciate anyone who took time to look over the post even if you couldn't find anything, the thought counts. :)

image.png
image.png (52.33 KiB) Viewed 9634 times

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], mikeyww and 111 guests