Author |
Topic  |
DavidRhodes
Senior Member
   
United Kingdom
1222 Posts |
Posted - 14 April 2005 : 12:19:56
|
Try and use the .NET data providers System.Data.SqlClient and steer clear of recordsets, use DataReader, DataSet, DataTable etc |
The UK MkIVs Forum |
 |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 14 April 2005 : 12:31:20
|
Ay, as you can see above, that's the direction I've gone in thanks to Ghost - just having trouble reading from the datareader object now.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
 |
|
Ghostnetworks
New Member

95 Posts |
Posted - 14 April 2005 : 12:50:12
|
In context, your code should look like this..
dim objConn as new odbcconnection("driver=MySQL;server=localhost;uid=username;pwd=password;database=database;")
dim objComm as new odbccommand("SELECT FIELDS FROM TABLE WHERE FIELD=VALUE",objConn)
objConn.open()
dim rs as odbcdatareader=objComm.executereader()
dim strString as string
While rs.Read()
strString = rs.GetString(0)
End While
rs.close()
objConn.close()
I've realized, in the longer run, it's easier to delcare a field as a name instead of the row number.. As in..objDataReader("MyField").ToString() ..Because it's easier to remember what I'm calling and storing. The numbers will do fine if it's a small query, but for longer returns it may be confusing to keep track of all the returned row numbers. Unless I'm on my third cup of coffee, I can't do it  |
 |
 |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 14 April 2005 : 13:00:07
|
Cheers, Ghost; will give that a whirl in the morn' let you know how I get on. What I'm working on is a small query, by the way, only returning one field from one record.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
 |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 15 April 2005 : 07:11:30
|
Huzzah! Finally got it working Many thanks, Ghost I'd missed the While statement when copying from that page on MSDN, probably a good indication that my upcoming holidays are long overdue (first in 2 years!) Anyway, for wnyone else who may happen across this topic, this is what I have now:<%@import namespace="system.data.odbc"%>
dim objConn as new odbcconnection("driver=MySQL;server=localhost;uid=username;pwd=password;database=database;")
dim objComm as new odbccommand("SELECT FIELDS FROM TABLE WHERE FIELD=VALUE",objConn)
objConn.open()
dim rs as odbcdatareader=objComm.executereader()
dim strString as string
while rs.read()
strString=rs.getstring(0)
end while
rs.close()
objConn.close() Nearly finished my thumbnail generator, now, just need to figure out how to add some transparent pixels to the edges of those thumbnails that are less than 100 square pixels, but that can wait 'eil I get back. 
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
 |
|
Etymon
Advanced Member
    
United States
2393 Posts |
Posted - 29 April 2005 : 06:19:57
|
Hi Shaggy,
I'm trying to convert this:
strSql = "SELECT " & strTablePrefix & "TOPICS.T_STATUS " & strTablePrefix & "TOPICS.T_SUBJECT" & strTablePrefix & "TOPICS.T_DATE "
strSql = strSql & "FROM " & strTablePrefix & "TOPICS "
strSql = strSql & "WHERE " & strTablePrefix & "TOPICS.TOPIC_ID = " & topicid
set rs = my_Conn.Execute(strSql)
topicstatus = rs("T_STATUS")
topicsubject = rs("T_SUBJECT")
topicdate = rs("T_DATE")
rs.close
set rs = nothing
into your code. I came up with this below:
<%@import namespace="system.data.odbc"%>
dim objConn as new odbcconnection("driver=MySQL;server=localhost;uid=username;pwd=password;database=database;")
dim objComm as new odbccommand("SELECT FIELDS FROM TOPICS WHERE TOPIC_ID=" & topicid & ",objConn)
objConn.open()
dim rs as odbcdatareader=objComm.executereader()
dim strString as string
while rs.read()
strString=rs.getstring(0)
end while
rs.close()
objConn.close()
----------------------
How do I convert:
topicstatus = rs("T_STATUS")
topicsubject = rs("T_SUBJECT")
topicdate = rs("T_DATE")
to what I need?
Thank you for posting this discussion. 
Cheers,
Etymon
|
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 29 April 2005 : 06:46:55
|
What Podge posted above should be contained within the while statement in my last post, where I have rs.getstring(0). To place Podge's examples within that code, you'd need to change odbcdatareader to rs or whatever name you give to your data reader object.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
 |
|
Etymon
Advanced Member
    
United States
2393 Posts |
Posted - 29 April 2005 : 07:03:38
|
Thanks guys,
I'll give it a try.
|
 |
|
Etymon
Advanced Member
    
United States
2393 Posts |
Posted - 29 April 2005 : 07:26:34
|
Hmmm ....
Now how do I write the variable topicstatus into my code?
Response.Write topicstatus doesn't seem to work.
Any links to doing this kind of thing is fine too. 
Etymon
|
 |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 29 April 2005 : 07:36:27
|
As far as I know, you have to have parentheses when calling a function or subroutine in .NET, not like classic ASP where they could be left out in certain situations. So you need:
response.write(topicstatus)
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
 |
|
Etymon
Advanced Member
    
United States
2393 Posts |
Posted - 29 April 2005 : 07:42:05
|
Ah, ok.
Um, how about this:
" & topicstatus & "
|
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
|
Topic  |
|