How to connect your web script with MS SQL Server? (version not important)
I must be the only noob who doesn't know how to use it but I spent a working day just to get the connection setting right. I get paid for that, so I must return some knowledge to the society. I installed SQL Server 2000 happily, thinking that it will be as intuitive as any other software that I have seen, but there are still some traps here and there.
During installation, I was asked questions that I did not know understand and I did not have the installation manual with me to teach me what each option meant, so I just clicked whichever I thought sounded more correct. If you ask me now what I chose for the various options, I will not be able to tell you because I really didn't know a single thing. The wizard then popped out to guide me through more installations which I did not know what it was for until I deleted something and then it was "Eureka! So that was what the wizard did!"
All other settings are quite standard but the problematic setting is the mixed mode authentication which really doesn't make any sense to a noob. There are two kinds of authentication methods, or rather methods for you to connect to the sql server. The first method, which doesn't work if you are using 3rd party scripts/programs to call it, is the windows authentication. It is a pop up window that requires you to type in your username and password. Up till now, I still don't understand how it works, but the username and password should be the one used to login the machine that contains the harddisk that stores the sql database. It's confusing right? For example, you are a client PC and your sql database is on a network. You also need to install MS SQL Server on your client PC if you want to read/write/execute queries on the database. The windows authentication in this case will pop up a window or something and ask you to select the database, mynetwork/db1, for example. After that, you have to enter the username and password to access that database, which is also called the database server.
Ah... so long-winded. The mixed mode is the one that is most commonly used. It allows windows authentication and sql server login. The additional login here is the sql server login which actually lets you connect to the sql server by scripts. The username and password used will be the same as in the windows authentication method. In the script, your connection statement will be something like this:
DATABASE=databasename;SERVER=servername;UID=username;Password=password
However, noobs like me don't know how to fill those items in. When I opened the sql software, I looked at the different folders, and added a database in, thinking that it will work but it didn't. *haha* By defualt, the database name is "master". I don't know how to do other fanciful stuff, but the very least, anybody should know that the default database is "master" because this will save you the time hunting every corner for your table. The username and password is also very tricky because throughout the installation process, I did not recall filling in information to create a user or anything to that extent.
The default username is "sa" and the password can be set to anything you fancy, but no noob will know where to find it. I searched microsoft.com for quite some time before I saw the light. Every database has its set of permitted users, so double click on the database, go to "Users", then you see the users. If you don't see any user or the "Login Name" field is empty, or you see the login name but don't know the password, or whatever, go to Security/Logins to create a new login. You will not be able to add a user into Databases/dbname/Users if the user login hasn't been created. Right click, and you should see a New Login option. Everything else is self explanatory but just remember to select "SQL Server Authentication".
No ODBC setup, that I initially thought would be needed, was required when I was meddling with the settings.
Noob for today, not a noob tomorrow.
