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 - 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
6 2012
Make sure that your database is configured to allow your account to log in remotely...and make sure that your connection string is correct.
-Frinny
Make sure that your database is configured to allow your account to log in remotely...and make sure that your connection string is correct.
-Frinny
Are you using SQL 2005 Express? If so, is IIS and SQL Server running on the same box? The reason I ask is that SQL Server 2005 Express doesn't allow remote connections from different machines on your network, so you will see security issues if the two are on different boxes...
It's talking to a sql 2000 server db that I query several times both automatically and from user interactions. All the other queries are working fine.
Thanks for the help, I stumbled into it, running back thru things again. it was changing the date format on the date variable I was putting in that query.
Thanks for the help, I stumbled into it, running back thru things again. it was changing the date format on the date variable I was putting in that query.
Yeah you really have to watch the Culture settings.
If you are saving dates as an "en-US" culture and the person using the system is running under "fr-FR" then the dates will be formatted incorrectly. Look into using the DateTimeFormatInfo object found in the System.Globalization namespace to help format your dates correctly for storage.
Did you fix the problem?
-Frinny
Yeah you really have to watch the Culture settings.
If you are saving dates as an "en-US" culture and the person using the system is running under "fr-FR" then the dates will be formatted incorrectly. Look into using the DateTimeFormatInfo object found in the System.Globalization namespace to help format your dates correctly for storage.
Did you fix the problem?
-Frinny
Yep, I just wrapped the passed date in a format (string, "MM/dd/yyyy") and it worked perfectly. I'll have to check that DateTime thing, sounds like it could be handy. The added fun is with this database some of the dates are MM/dd/yyyy, some are MM/dd/yy, some are MM/dd/yyyy HH:MM:SS, and some are yyyyddMM. I think the people that originally set it up couldn't make up their minds :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Arvind P Rangan |
last post by:
Hi All,
How do you get all the values of a sqldatareader if it
contains multiple resultset.
Using sqldatareader.nextresult and sqldatareader.read
e.g.
While sqldatareader.read '
If not...
|
by: bidllc |
last post by:
I have a funtion that works fine and dandy when called from anywhere in my
app. It will NOT work when called from inside the class in which it resides.
This is the function I'm calling:...
|
by: mimi |
last post by:
Hi
Please help me out, I can't find a way to close a sqldatareader when error
occur at statement cmd.ExecuteReader(). I can't close it in catch because
it is local in try scope and I can't...
|
by: Cameron Frasnelly |
last post by:
I emulated the code from the .Net Framework help (Titled "Using Stored
Procedures with a Command") and I still receive and error...
Error Received = "Invalid attempt to read when no data is...
|
by: James P. |
last post by:
I'm trying to pass a sqlDataReader from a called function to a calling
function but got nothing back and a message saying "An unhandled
exception of type 'System.NullReferenceException' occurred in...
|
by: Web learner |
last post by:
I am trying to create a method GetDataFor(string column) becaues I have to repeat the same statements for several columns but I get an error as follows:
The name 'dr' does not exist in the current...
|
by: Jon Haakon Ariansen |
last post by:
Hi,
I realize that it's not possible to get the rowcount from SqlDataReader, but
if you have a stored procedure where you return @@ROWCOUNT it should be
possible to get the rowcount through the...
|
by: nayla |
last post by:
I am using 2 SqlDataReader and while(dr.Read()) get only first record and loop stops. its not retriving all of the records but if I comment
db1.RunSQLStatement(sql1,out unit_dr);
while...
|
by: Cirene |
last post by:
I have a sqldatareader that I use to read some data. Later I do a dr.close.
In the same sub I later to "dr = MyCommand.ExecuteReader" because I'm trying
to reuse the var with a totally different...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |