Showing posts with label reading. Show all posts
Showing posts with label reading. Show all posts

Monday, March 26, 2012

Invalid object name while reading data out of an SQL Database

Hi all,
I'm a complete newbie on ASP.Net.

I want to get some data out of a SQLserver Database running on my system with SQL Server 2005 Express. The name of the Database is 'tempdb' and the table is called "Members". the SQLServer runs as Local System with the Windows account.

When I try to open the site, I always get the same error:
Invalid object name 'Members'

I don't know what to do anymore. I read a post, where anybody set the rights for the owner, but my database is running with the Windows account.

Here is the Code of the page so far:

<%@. Page Language="VB" Debug="True" Strict="True" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SQlClient" %>
<script runat="server">
Sub Page_Load (ByVal Sender As Object, _
ByVal E As EventArgs)

Dim connStr As String
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;"
connStr += "database=tempdb;"
connStr += "Truster_Connection=yes"
Dim conn As New SQLConnection(connStr)
conn.Open()

Dim sql As String
sql = "SELECT COUNT (*) FROM Members"
Dim cmd As New SQLCommand(sql, conn)
Dim ergebnis As String
ergebnis = cmd.ExecuteScalar().toString()
Dim t As String
t = "Die Tabelle Members hat " & _
ergebnis & " Zeilen. <br>" & _
"Das Kommando lautet: " & _
cmd.CommandText & "<br>" & _
"Der Kommandotyp ist: " & _
cmd.CommandType

ausgabe.innerHTML = t

End Sub
</script>
<html><head><title>
Demo zu SQLCommand.ExecuteScalar
</title></head>
<body>
<h3>Demo zu SQLCommand.ExecuteScalar</h3>
<p runat="server" id="ausgabe" />
</body></html>

Thanks for your help an sorry for my english.

Greets
Flash_Prince

The problem is objects in tempdb is valid for limited time so your object the Member table does not exist. Microsoft provided the tempdb for SQL Server to be used to proccess complex queries and test queries so when you create a table if you did not drop it SQL Server will drop it at some point. Try the links below to download sample databases you can create and use with SQL Server 2005. The databases comes with tables but you can create your own tables so you can add the member table to any of the three database. Hope this helps.


http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46A0-8DA2-EEBC53A68034&displaylang=en

http://www.microsoft.com/downloads/details.aspx?FamilyID=e719ecf7-9f46-4312-af89-6ad8702e4e6e&DisplayLang=en

|||

The problem is, that i want to use the database without entering the path of the database file in the sourcecode. When I use the nordwind database, all the sql queries are working very well. But if I use the Nordwind Database, I only know to connect by OleDB.

Can you tell me how to use a database in the way decribed above with a sql connection?

I hope, this is described understandable, cause my english is not the best.

|||

You need to create connection string and most of the information you need is covered in the two links below. Hope this helps.

http://www.connectionstrings.com

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000010.asp

|||The problem is in your connection string. You have a typo: "Truster_Connection=yes" should be "Trusted_Connection=yes".

Wednesday, March 21, 2012

Invalid non-ASCII character conversion over JDBC to Solaris client

Hi,

I'm working on a database conversion from Sybase to SQL Server 2005 and have hit a wall with a character conversion problem when reading non-ASCII characters (encrypted password) via JDBC.

My application runs on Solaris and accesses a SQL Server 2005 database via the Microsoft JDBC driver. The server was unfortunately specified as having a SQL_Latin1_General_CP1_CI_AS collation at installation time, and the database being accessed has taken this default. After creation the data was migrated across via DTS.

The invalid character is a dagger '?'. When read over JDBC it is converted to a question mark '?'.

In my original environment a Sybase database was accessed via JDBC driver from Solaris and the correct value was returned. The Sybase database used Latin1_General_BIN as it's collation. By way of experimentation I have modified the default collation sequence within the SQL Server 2005 database, and created a new table to hold the password. I am then able to correctly return strings containing this character from within SQL Server Management Studio, but the same problem still exists when accessing it via JDBC.

I am not sure where to focus my investigation and would be grateful for any useful pointers/advice. To me it looks like it's a JDBC driver issue as with the change in collation it works from a non-JDBC client.

Many thanks

Alistair

Just to make sure we are on the same page, are you using the Microsoft 2005 Jdbc driver?

http://msdn.microsoft.com/data/ref/jdbc/

We have just shipped the June community tech preview of this driver if you want to play with the latest and greatest:

http://www.microsoft.com/downloads/details.aspx?familyid=f914793a-6fb4-475f-9537-b8fcb776befd&displaylang=en

The Microsoft 2000 Jdbc driver is not supported here. If you are using the latest driver do you have some code that inserts the invalid data into the database and then returns it incorrectly? I would be happy to take a look at this.

|||

Thank you for the reply. I have been using the 2005 driver, but have managed to resolve the problem by changing the column data type to a binary rather than varchar.

Out of interest do you have any idea when the new driver will go on general release?

|||

Glad to hear you got this working!

We are currently working on shipping the v1.1 release of the 2005 JDBC driver, of course I can't promise anything but we are targetting an August release date.

|||

Hi,

Please can you update me on the shipping date for the v1.1 release of the 2005 JDBC driver? Is it likely to be within the next couple of weeks?

Regards,

Alistair

|||

Hi Alistair,

Yes, the v1.1 release should be available within the next couple of weeks. It may even be available as early as next week.

Thank you,

--David Olix

JDBC Development

sql

Invalid non-ASCII character conversion over JDBC to Solaris client

Hi,

I'm working on a database conversion from Sybase to SQL Server 2005 and have hit a wall with a character conversion problem when reading non-ASCII characters (encrypted password) via JDBC.

My application runs on Solaris and accesses a SQL Server 2005 database via the Microsoft JDBC driver. The server was unfortunately specified as having a SQL_Latin1_General_CP1_CI_AS collation at installation time, and the database being accessed has taken this default. After creation the data was migrated across via DTS.

The invalid character is a dagger '?'. When read over JDBC it is converted to a question mark '?'.

In my original environment a Sybase database was accessed via JDBC driver from Solaris and the correct value was returned. The Sybase database used Latin1_General_BIN as it's collation. By way of experimentation I have modified the default collation sequence within the SQL Server 2005 database, and created a new table to hold the password. I am then able to correctly return strings containing this character from within SQL Server Management Studio, but the same problem still exists when accessing it via JDBC.

I am not sure where to focus my investigation and would be grateful for any useful pointers/advice. To me it looks like it's a JDBC driver issue as with the change in collation it works from a non-JDBC client.

Many thanks

Alistair

Just to make sure we are on the same page, are you using the Microsoft 2005 Jdbc driver?

http://msdn.microsoft.com/data/ref/jdbc/

We have just shipped the June community tech preview of this driver if you want to play with the latest and greatest:

http://www.microsoft.com/downloads/details.aspx?familyid=f914793a-6fb4-475f-9537-b8fcb776befd&displaylang=en

The Microsoft 2000 Jdbc driver is not supported here. If you are using the latest driver do you have some code that inserts the invalid data into the database and then returns it incorrectly? I would be happy to take a look at this.

|||

Thank you for the reply. I have been using the 2005 driver, but have managed to resolve the problem by changing the column data type to a binary rather than varchar.

Out of interest do you have any idea when the new driver will go on general release?

|||

Glad to hear you got this working!

We are currently working on shipping the v1.1 release of the 2005 JDBC driver, of course I can't promise anything but we are targetting an August release date.

|||

Hi,

Please can you update me on the shipping date for the v1.1 release of the 2005 JDBC driver? Is it likely to be within the next couple of weeks?

Regards,

Alistair

|||

Hi Alistair,

Yes, the v1.1 release should be available within the next couple of weeks. It may even be available as early as next week.

Thank you,

--David Olix

JDBC Development

Invalid non-ASCII character conversion over JDBC to Solaris client

Hi,

I'm working on a database conversion from Sybase to SQL Server 2005 and have hit a wall with a character conversion problem when reading non-ASCII characters (encrypted password) via JDBC.

My application runs on Solaris and accesses a SQL Server 2005 database via the Microsoft JDBC driver. The server was unfortunately specified as having a SQL_Latin1_General_CP1_CI_AS collation at installation time, and the database being accessed has taken this default. After creation the data was migrated across via DTS.

The invalid character is a dagger '?'. When read over JDBC it is converted to a question mark '?'.

In my original environment a Sybase database was accessed via JDBC driver from Solaris and the correct value was returned. The Sybase database used Latin1_General_BIN as it's collation. By way of experimentation I have modified the default collation sequence within the SQL Server 2005 database, and created a new table to hold the password. I am then able to correctly return strings containing this character from within SQL Server Management Studio, but the same problem still exists when accessing it via JDBC.

I am not sure where to focus my investigation and would be grateful for any useful pointers/advice. To me it looks like it's a JDBC driver issue as with the change in collation it works from a non-JDBC client.

Many thanks

Alistair

Just to make sure we are on the same page, are you using the Microsoft 2005 Jdbc driver?

http://msdn.microsoft.com/data/ref/jdbc/

We have just shipped the June community tech preview of this driver if you want to play with the latest and greatest:

http://www.microsoft.com/downloads/details.aspx?familyid=f914793a-6fb4-475f-9537-b8fcb776befd&displaylang=en

The Microsoft 2000 Jdbc driver is not supported here. If you are using the latest driver do you have some code that inserts the invalid data into the database and then returns it incorrectly? I would be happy to take a look at this.

|||

Thank you for the reply. I have been using the 2005 driver, but have managed to resolve the problem by changing the column data type to a binary rather than varchar.

Out of interest do you have any idea when the new driver will go on general release?

|||

Glad to hear you got this working!

We are currently working on shipping the v1.1 release of the 2005 JDBC driver, of course I can't promise anything but we are targetting an August release date.

|||

Hi,

Please can you update me on the shipping date for the v1.1 release of the 2005 JDBC driver? Is it likely to be within the next couple of weeks?

Regards,

Alistair

|||

Hi Alistair,

Yes, the v1.1 release should be available within the next couple of weeks. It may even be available as early as next week.

Thank you,

--David Olix

JDBC Development

Friday, March 9, 2012

Invalid character in XML

I'm using XML EXPLICIT to query some data which may contain some invalid XML
characters. While I'm reading in the data I get an error. Other than
removing the characters before the data is inserted into the database, is
there a way to handle (or omit) reading the invalid characters?
Thanks.Steve,
Have you thought about escaping the invalid characters? You can escape using
either &<decimal>; or &x<hexadecimal>;
Thanks,
Amol
"SteveISOA" wrote:

> I'm using XML EXPLICIT to query some data which may contain some invalid X
ML
> characters. While I'm reading in the data I get an error. Other than
> removing the characters before the data is inserted into the database, is
> there a way to handle (or omit) reading the invalid characters?
> Thanks.|||Amol,
At what point can you escape the invalid characters? I do not want to
modify the existing data in the database, and I'm using a very simple proces
s
of reading and writing the data. It looks something like this:
...
SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
...
XmlTextWriter txtWriter = new XmlTextWriter(...);
XmlReader xmlReader = mCommand.ExecuteXmlReader();
while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
{
txtWriter.WriteNode(xmlReader,false);
}
...
Thanks again.
Steve
"Amol Kher" wrote:
> Steve,
> Have you thought about escaping the invalid characters? You can escape usi
ng
> either &<decimal>; or &x<hexadecimal>;
> Thanks,
> Amol
> "SteveISOA" wrote:
>|||Steve,
The escaping should happen before the reader is created. But looks like you
dont have control over the reader creation. Once the reader is created, it
will work off the stream and if you can somehow intercept this stream then
you can replace it there.
Unfortunately invalid characters in XML is not allowed by the XML Spec so
the best solution is if you can fix it when the data gets in and not when yo
u
pull it out. Even if you find a solution to work around this issue,
potentially this is a compatibility issue with other compliant parsers.
Thanks,
Amol
"SteveISOA" wrote:
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple proc
ess
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
>|||You need to ensure that all binary columns or char columns which has invalid
char values like 0xa, 0xb are binary encoded with encodings like binbase64.
--
Bertan ARI
This posting is provided "AS IS" with no warranties, and confers no rights.
"SteveISOA" <SteveISOA@.discussions.microsoft.com> wrote in message
news:385305A5-2C52-4843-A93B-36D209ED13DD@.microsoft.com...
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple
> process
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
>|||Assuming that the characters are invalid not because of the wrong encoding
(FOR XML results are UTF-16 encoded which means that you need to set it
accordingly on the client side), you have to filter the invalid characters
out in your TSQL code. There may be some non-standard option on the XML
parser that allows you to parse the invalid characters in System.XML, but I
am not sure about that.
Best regards
Michael
"SteveISOA" <SteveISOA@.discussions.microsoft.com> wrote in message
news:385305A5-2C52-4843-A93B-36D209ED13DD@.microsoft.com...
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple
> process
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
>

Invalid character in XML

I'm using XML EXPLICIT to query some data which may contain some invalid XML
characters. While I'm reading in the data I get an error. Other than
removing the characters before the data is inserted into the database, is
there a way to handle (or omit) reading the invalid characters?
Thanks.
Steve,
Have you thought about escaping the invalid characters? You can escape using
either &<decimal>; or &x<hexadecimal>;
Thanks,
Amol
"SteveISOA" wrote:

> I'm using XML EXPLICIT to query some data which may contain some invalid XML
> characters. While I'm reading in the data I get an error. Other than
> removing the characters before the data is inserted into the database, is
> there a way to handle (or omit) reading the invalid characters?
> Thanks.
|||Amol,
At what point can you escape the invalid characters? I do not want to
modify the existing data in the database, and I'm using a very simple process
of reading and writing the data. It looks something like this:
...
SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
...
XmlTextWriter txtWriter = new XmlTextWriter(...);
XmlReader xmlReader = mCommand.ExecuteXmlReader();
while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
{
txtWriter.WriteNode(xmlReader,false);
}
...
Thanks again.
Steve
"Amol Kher" wrote:
[vbcol=seagreen]
> Steve,
> Have you thought about escaping the invalid characters? You can escape using
> either &<decimal>; or &x<hexadecimal>;
> Thanks,
> Amol
> "SteveISOA" wrote:
|||Steve,
The escaping should happen before the reader is created. But looks like you
dont have control over the reader creation. Once the reader is created, it
will work off the stream and if you can somehow intercept this stream then
you can replace it there.
Unfortunately invalid characters in XML is not allowed by the XML Spec so
the best solution is if you can fix it when the data gets in and not when you
pull it out. Even if you find a solution to work around this issue,
potentially this is a compatibility issue with other compliant parsers.
Thanks,
Amol
"SteveISOA" wrote:
[vbcol=seagreen]
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple process
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
|||You need to ensure that all binary columns or char columns which has invalid
char values like 0xa, 0xb are binary encoded with encodings like binbase64.
Bertan ARI
This posting is provided "AS IS" with no warranties, and confers no rights.
"SteveISOA" <SteveISOA@.discussions.microsoft.com> wrote in message
news:385305A5-2C52-4843-A93B-36D209ED13DD@.microsoft.com...[vbcol=seagreen]
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple
> process
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
|||Assuming that the characters are invalid not because of the wrong encoding
(FOR XML results are UTF-16 encoded which means that you need to set it
accordingly on the client side), you have to filter the invalid characters
out in your TSQL code. There may be some non-standard option on the XML
parser that allows you to parse the invalid characters in System.XML, but I
am not sure about that.
Best regards
Michael
"SteveISOA" <SteveISOA@.discussions.microsoft.com> wrote in message
news:385305A5-2C52-4843-A93B-36D209ED13DD@.microsoft.com...[vbcol=seagreen]
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple
> process
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote: