I have a function that cals a sql database and spits the rows back to an arraylist for me to do whatever with. I've not had any trouble with it till I ran into this. I pulled some values, copied them to another arraylist and based on the id numbers I run a second query to determine a color change in the html table I'm outputting. My problem is it works perfect when I run in visual studio, however, when I publish it and try it it finds nothing (the read() returns false regardless). I've checked and it is getting the correct sql query passed to it. Any ideas why it might do this?
Thanks
Patrick
Thanks
Patrick
Code:
Shared Sub sqlcmd(ByVal returned As Integer, ByVal query As String, ByVal getdata As Boolean) 'returned is how many fields are returned 'query is the sql query to be run 'getdata is a switch for whether to load data or not. Dim sql As New System.Data.SqlClient.SqlCommand(query, sqlconn) sqlconn.Open() If getdata Then dr = sql.ExecuteReader() Dim j = 0 Dim i count = returned b.Clear() 'make sure the arraylist is empty While dr.Read() For i = 0 To returned - 1 b.Add(dr(i)) Next b.TrimToSize() 'sets b as an arraylist 'every "returned/count" is a row j = j + 1 End While Else sql.ExecuteNonQuery() 'if getdata\=false...Ex: an update query End If dr.Close() sqlconn.Close() End Sub
Comment