I don't need advice on how to set it up because I followed some tutorial on how to set it up and what not:
http://www.devarticles.com/c/a/ASP/U...abase-Via-ASP/
And I ran the sample code shown in the tutorial, and it works just fine. I just need to know how to do one really simple thing: how do I display records? In other words, I want to do something like this:
Code:
<%
'on error resume next
dim adoConn
dim adoRS
dim strQuery
set adoConn = Server.CreateObject("ADODB.Connection")
set adoRS = Server.CreateObject("ADODB.Recordset")
adoConn.Open "DSN=mysql_dsn"
strQuery = "select * from contacts"
adoConn.Execute strQuery
adoRS.ActiveConnection = adoConn
'do while not adoRS.EOF
response.write adoRS.fields(0).value
response.write("it did stuff")
'adoRS.MoveNext
'loop
adoConn.Close
%>
But apparently this line:
response.write adoRS("contactId")
has something wrong with it. I tried variations like:
response.write adoRS.fields("contactId")
response.write adoRS.fields("contactId").value
response.write adoRS.fields(0).value
but none of them work. I don't know of I need to open the database or the connection in a different way just to be able to read it (which would be strange, because according to the samples on the tutorial I linked, you can add records and delete records without having to connect to the database in any special or particular way
)
And I've searched Google, but it just seems that no one is interested in using MySQL with ASP (since the popular choice is simply to access MySQL through PHP, but I'd rather not have to learn PHP unless it is completely necessary, since I already know ASP). I'm not saying I'll never learn PHP, but I first just want to expand my experience with working with databases. Once I'm comfortable with working with databases I'll move on to bigger and better things.
I'm also 100% positive that the database is not empty, 'cause I'd be getting an end-of-file error message before it gets to the erroneous line that I pointed out above, and I can see the recordset in SQLyog (cool frontend for MySQL which I'm sure most of you know about already) anyway, so I know it is there.
Anyone know how to accomplish this simple task in ASP?
EDIT: D'oh! I see a huge mistake I made. HUGE mistake. I shall fix it and repost in a few...
EDIT 2: Okay, I modified the code... but that same line is still giving me problems.
EDIT 3: Updated the code yet again, and now it just completely sits there. No error messages or anything, so I added a little debug line just to make sure it is alive, and sure enough there it is, the little message "it did stuff", but it still refuses to display any data from the database.
EDIT 4: Updated the code again. This nonsense is so infuriating; why can't they design these things more intuitively already? >_<