PDA

View Full Version : Any SQL experts on here?



Penguin
9/19/2011, 01:28 PM
I'm not even sure if I know enough to even formulate an intelligent question, but here goes. What is SQL? Is it a language? Is it a program like Access? How do I use C# to talk to an SQL database? (if that question makes sense)


I'm embarrassed to even ask for help because usually most computer programming topics come naturally to me. However, I find this to be a head scratcher. I've been assigned a "project" where the only guidelines are to use C# and use SQL. And then I was told, "Use ADO.net. It makes it easy!" Um, ok. What is ADO.net?

Google gives me about a bajillion results. I'm not even sure where to start.


Please help. I require instruction.

Partial Qualifier
9/19/2011, 01:34 PM
You can create sql *scripts*, which I suppose can be called 'programming' but sql is not a programming language. SQL is a database query language.

You have a database and need to do things with it's data - create reports, export information, even change the data structure - you'd use sql.

There are some dudes on here who know this stuff alot better than I. Veritas, JKM, etc.

Partial Qualifier
9/19/2011, 01:37 PM
C# is your programming language. SQL is the language which your C# app will use to "get stuff" from the database. I'm guessing ADO.NET is canned SQL query syntax which you can call with your C# application.

sooner_born_1960
9/19/2011, 01:40 PM
ADO.net is the mechanism that your program will connect/query/update the database. Thank of it as an API into your database. Sorta.

sooner_born_1960
9/19/2011, 01:41 PM
I'm just a DBA, though. The developers could give you a better answer. Sadly, they don't post here.

Penguin
9/19/2011, 01:43 PM
Thanks. It's so frustrating trying to find good information. I started looking at a "tutorial" website until I realized the website was created in 2004. I don't know. As far as I know, 2004 might be current. But, as far as the computer world goes, anything older than 2 years is usually obsolete.

All of the intro to SQL videos on Youtube are 2-4 years old.

NormanPride
9/19/2011, 02:03 PM
Structured
Query
Language

It is a simple (though it is getting more complex) language to access data in various database systems. Each system has their own flavor, but they are mostly the same. i.e.


SELECT column_1, column_2
FROM table_name
WHERE column_1 > 500
AND column_2 = 'OU'

Do you know much about databases? jkm could probably school me on this (as well as Veritas) but I can teach enough to get you started. FWIW, basic SQL has not changed much at all since I started working with it over six years ago. New things are added, but basic SQL has stayed the same.

GDC
9/19/2011, 02:17 PM
I don't know, I had Fortran back in the mid-80s.

XFollower
9/19/2011, 02:39 PM
I could tell you pretty clearly with java, but I don't have a lot of experience with C#. I know the 2 are very similar. What is the database, Oracle, SQL server, mysql, etc? What part is freaking you out?

Penguin
9/19/2011, 03:33 PM
I could tell you pretty clearly with java, but I don't have a lot of experience with C#. I know the 2 are very similar. What is the database, Oracle, SQL server, mysql, etc? What part is freaking you out?

Actually, the data is contained in an Excel file. I'm guessing I have to convert it somehow? It will need to be a SQL Server database.

NormanPride
9/20/2011, 07:24 AM
Yeah, I think SQL Server has an import wizard of some sort to get xls files into database format. Once you do that, you need to set up a database access method in your code I would imagine. Something that accepts a string of sql or the like, and has all the connection information to use that sql on the database and return a recordset. I know there are nicer ways to do it, but that's the gist of things.

crawfish
9/20/2011, 01:42 PM
Years ago in C# I used Linq, which was new at the time and seemed pretty easy to use. Mind you, I was doing some pretty lightweight database use. Lookup "linq to sql" in google to find references. I think the advantage is it's native to C#.

crawfish
9/20/2011, 01:44 PM
And CodeProject is usually a good place to go for examples. Here is a sample of doing ADO.NET in C#:

http://www.codeproject.com/KB/database/DatabaseAcessWithAdoNet1.aspx

soonerboomer93
9/20/2011, 01:51 PM
yeah, tSQL (Microsoft SQL) has an import function, you can also download sql express for free from Microsoft.
SQL is a database engine, but it doesn't have the internal capabilities to make a fancy front end like access.


(not sure about oracle or mySQL)

http://www.microsoft.com/sqlserver/en/us/editions/express.aspx

jkjsooner
9/20/2011, 01:56 PM
I don't think you have to worry much about SQL changing over the last couple of years. Each database vendor has extensions to SQL which may change but the basic SQL has been around for decades.

SQL is pretty simple once you get the hang of it. The best thing is to download a tutorial, download a free copy of a database (mysql is an easy one to download), and run through making some tables, inserting data, updating data, and querying data. You'll be amazed at how powerful it can be.


Once you've learned SQL, using SQL in a programming language is usually pretty easy. I've never done C# but in Java you basically hold your query in a string and send it to the server. The results are held in some type of data structure.