Showing posts with label retrieve. Show all posts
Showing posts with label retrieve. Show all posts

Friday, March 23, 2012

'Invalid object name'

Dear all,
I've got an issue which to encompass both sql and vb and I can't work out.
I'm trying to retrieve data from an ASP page by ADO 2.6 and appears the
following error:
"
Microsoft OLE DB Provider for SQL Server error '80040e37'
Invalid object name 'GEN_VentDesp'.
/mtotgen/pruebas.asp, line 8
"
Snippet of code:
<%
set cnn=Server.CreateObject("ADODB.Connection")
ConectarBD(cnn)
sql = "SELECT * FROM GEN_VentDesp"
set rs = cnn.Execute(sql)
%>
I haven't idea why happens this. Moreover 'GEN_VentDesp' object exists on
the database (sql2k) and the user for that connection own the fine
permissions so that
I'm stuck..
Does anyone ever user or experienced this kind of error'
Thanks in advance,Could be few things. Check if you are connected to the database that
the objects exist in. Also check who owns the object. If the object
is not owned by the dbo and the object's owner is not the user that you
use in the connection string, then you need to specify the owner's name
as part of the object's name.
Adi|||Also check that the user you are logging in as has access to the object.
Connecting to Query Analyzer using the same login, and running the SQL
manually is the best test. If that works then it should work in your code.
If it does not work, then your SQL Connection, object name, or permissions
are wrong. Basically, get it working in the database to eliminate any
database issues, then put it into your app and is issues arrive you will
know they are the app and not the database.
"Adi" <adico@.clalit.org.il> wrote in message
news:1147338575.972058.140510@.g10g2000cwb.googlegroups.com...
> Could be few things. Check if you are connected to the database that
> the objects exist in. Also check who owns the object. If the object
> is not owned by the dbo and the object's owner is not the user that you
> use in the connection string, then you need to specify the owner's name
> as part of the object's name.
> Adi
>sql

Friday, March 9, 2012

invalid cab file after snapshot via FTP

I was able to successfuly retrieve a snapshot via FTP but the subscriber says
the snapshot .cab within the folder is invalid. What would make the file
invalid?
Jeffrey, this looks rather strange indeed. Which version of SQL server are
you running? Is the cab file marked read-only by any chance? Can you browse
the content of snapshot.cab directly in Explorer? Were there any strange
error messages in the snapshot agent history table? Does the problem go away
if you regenerate the snapshot?
-Raymond
"Jeffrey K. Ericson" wrote:

> I was able to successfuly retrieve a snapshot via FTP but the subscriber says
> the snapshot .cab within the folder is invalid. What would make the file
> invalid?

Wednesday, March 7, 2012

Invalid attempt to read when no data is present

I am using a standard dbreader type of loop in a query to retrieve data. I am running over what should be end of record set, every time.

I have altered my read procedures to use while dbreader.read() and if dbreader.read(), to attempt to avoid getting the error. Neither is stopping it.

While debugging it, as I get to the last item and actually get the error, if I check the dbreader status, it still indicates that it has rows.

Anyone have any ideas on how to get around this?

TIA, Tom

Can you post your code?
|||

Sure can. The below posted is the whole thing. The sqlcommand, connection, etc. should be irrelavant.

' get the data from the database and pass it back.

Function getTheData(ByVal cmd As String) As DataTable

' note that the passed cmd is the below sqlString

Dim sqlString As String = "SELECT CONVERT(char(20), Date, 107) AS Date, City, State, Company, Position, JobNumber, Row_Number() Over (ORDER BY JobNumber DESC) as Item FROM JobsDB "

' define the new datatable to hold our results

dt = New DataTable("Jobs")

' define the columns we will be saving

Dim dcIt As New DataColumn("Item", GetType(String))

Dim dcDt As New DataColumn("Date", GetType(String))

Dim dcCt As New DataColumn("City", GetType(String))

Dim dcSt As New DataColumn("State", GetType(String))

Dim dcJN As New DataColumn("JobNumber", GetType(Integer))

Dim dcKW As New DataColumn("KeyWords", GetType(String))

Dim dcPos As New DataColumn("Position", GetType(String))

Dim dcCo As New DataColumn("Company", GetType(String))

' add columns

dt.Columns.Add(dcIt)

dt.Columns.Add(dcDt)

dt.Columns.Add(dcCt)

dt.Columns.Add(dcSt)

dt.Columns.Add(dcJN)

dt.Columns.Add(dcKW)

dt.Columns.Add(dcPos)

dt.Columns.Add(dcCo)

' define datarow

Dim dr As DataRow

' build sql command info

sqlCmd = New SqlCommand

sqlCmd.Connection = sqlConn

sqlCmd.CommandType = CommandType.Text

sqlCmd.CommandText = sqlString

Try

sqlConn.Open()

dbReader = sqlCmd.ExecuteReader()

If dbReader.HasRows Then

While dbReader.Read() 'this can be changed to if dbreader.read(), no diff

' build the data table item from the database

dr = dt.NewRow()

dr("Item") = dbReader.Item("Item").ToString()

dr("Date") = dbReader.Item("Date").ToString()

dr("City") = dbReader.Item("City").ToString()

dr("State") = dbReader.Item("State").ToString()

dr("JobNumber") = dbReader.Item("JobNumber").ToString()

dr("Position") = dbReader.Item("Position").ToString()

dr("Company") = dbReader.Item("Company").ToString()

dr("KeyWords") = keywords

dt.Rows.Add(dr)

End While

Else

lblNoData.Visible = True

End If

Catch ex As Exception

Dim exMsg As String = Request.ServerVariables("Script_Name") + ", getTheData(cmd=" & sqlString & "): msg=" + ex.Message.ToString()

utils.writeApplicationLog(exMsg, System.Configuration.ConfigurationManager.AppSettings("UtilityDbName"))

Response.Redirect(ConfigurationManager.AppSettings("errorPage") & ConfigurationManager.AppSettings("errCatchAll") & "&return=" & Request.ServerVariables("Script_Host"))

End Try

Return dt.Copy

End Function

Thanks, Tom

|||The code worked for me using sample data.

Some thoughts: Make the declarations of sqlConn, sqlCmd, and dbReader local to the function instead of global. Add a Finally section that contains dbReader.Close, sqlConn.Close, and sqlConn.Dispose.

If that doesn't change anything, is it possible that there's something in your data that is causing the problem?