MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Indexerstellung_mit

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> Compact Framework
Author Message
Dirk Michaelsen



Joined: 21 Dec 2007
Posts: 4

PostPosted: Mon Feb 04, 2008 11:54 am    Post subject: Indexerstellung_mit Reply with quote

Guten Morgen,

ich habe eine C#-Applikation geschrieben, die eine SQL Server Compact
Edition Datenbank für eine MDE-Anwendung erstellt. Das Füllen der
Datenbank funktioniert auch soweit sehr gut. Lediglich die Erstellung
der Indizes will einfach nicht funktionieren.

Zur Erstellung der Indizes verwende ich folgende Methode:

--- snip ---
private SqlCeConnection conn;
private SqlCeTransaction trans;

public void GenerateIndices()
{
Console.WriteLine("Erstelle Indizes");
try
{
trans = conn.BeginTransaction();

string[] indexDefinitions =
{
"CREATE INDEX ArtstmId ON Artikel (artstm_id)",
"CREATE INDEX ArtikelNr ON Artikel (artikel_nr)",
"CREATE INDEX MestmId ON Mengeneinheiten (mestm_id)",
"CREATE INDEX ArtstmId ON Mengeneinheiten
(artstm_artstm_id)",
"CREATE INDEX MestmId ON Ean (mestm_mestm_id)",
"CREATE INDEX Ean ON Ean (ean)",
"CREATE INDEX MestmId ON Konditionen (mestm_mestm_id)"
};

foreach (string index in indexDefinitions)
{
Console.WriteLine("sende SQL-Command: " + index);
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = index;
cmd.ExecuteNonQuery(); // dies ist Zeile 140
}
trans.Commit();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
--- snip ---

Bereits beim ersten Aufruf von cmd.ExecuteNonQuery() springt die
Anwendung in den Catch-Block mit der relativ nichtssagenden Meldung
"[Artikel]" und dem folgenden Exception-Stacktrace:

$exception {" [ Artikel ]"} System.Exception
{System.Data.SqlServerCe.SqlCeException}
bei System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
bei System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr&
pCursor, Boolean& isBaseTableCursor)
bei
System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior
behavior, String method, ResultSetOptions options)
bei System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
bei MDEDatenImport.DataConnection.GenerateIndices() in C:\Dokumente
und Einstellungen\dimich\Eigene Dateien\Visual Studio
2005\Projects\MDEDatenImport\MDEDatenImport\DataConnection.cs:Zeile
140.

Was mache ich falsch?

Gruß
Dirk

Archived from group: microsoft>public>dotnet>framework>compactframework
Back to top
View user's profile Send private message
Zachovich



Joined: 08 Aug 2007
Posts: 1

PostPosted: Sat Feb 09, 2008 12:41 pm    Post subject: RE:_Indexerstellung_mit_SQL_CE_n Reply with quote

Ist es möglich so wirst du einfach müssen "code snip" auf englisch
verdolmetschen, so du eine behilflige antwort becommen willst auf diese
newsgroup.

Entschuldigung bitte.


"Dirk Michaelsen" wrote:

> Guten Morgen,
>
> ich habe eine C#-Applikation geschrieben, die eine SQL Server Compact
> Edition Datenbank für eine MDE-Anwendung erstellt. Das Füllen der
> Datenbank funktioniert auch soweit sehr gut. Lediglich die Erstellung
> der Indizes will einfach nicht funktionieren.
>
> Zur Erstellung der Indizes verwende ich folgende Methode:
>
> --- snip ---
> private SqlCeConnection conn;
> private SqlCeTransaction trans;
>
> public void GenerateIndices()
> {
> Console.WriteLine("Erstelle Indizes");
> try
> {
> trans = conn.BeginTransaction();
>
> string[] indexDefinitions =
> {
> "CREATE INDEX ArtstmId ON Artikel (artstm_id)",
> "CREATE INDEX ArtikelNr ON Artikel (artikel_nr)",
> "CREATE INDEX MestmId ON Mengeneinheiten (mestm_id)",
> "CREATE INDEX ArtstmId ON Mengeneinheiten
> (artstm_artstm_id)",
> "CREATE INDEX MestmId ON Ean (mestm_mestm_id)",
> "CREATE INDEX Ean ON Ean (ean)",
> "CREATE INDEX MestmId ON Konditionen (mestm_mestm_id)"
> };
>
> foreach (string index in indexDefinitions)
> {
> Console.WriteLine("sende SQL-Command: " + index);
> SqlCeCommand cmd = conn.CreateCommand();
> cmd.CommandText = index;
> cmd.ExecuteNonQuery(); // dies ist Zeile 140
> }
> trans.Commit();
> }
> catch (Exception ex)
> {
> MessageBox.Show(ex.Message);
> }
> }
> --- snip ---
>
> Bereits beim ersten Aufruf von cmd.ExecuteNonQuery() springt die
> Anwendung in den Catch-Block mit der relativ nichtssagenden Meldung
> "[Artikel]" und dem folgenden Exception-Stacktrace:
>
> $exception {" [ Artikel ]"} System.Exception
> {System.Data.SqlServerCe.SqlCeException}
> bei System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
> bei System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr&
> pCursor, Boolean& isBaseTableCursor)
> bei
> System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior
> behavior, String method, ResultSetOptions options)
> bei System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
> bei MDEDatenImport.DataConnection.GenerateIndices() in C:\Dokumente
> und Einstellungen\dimich\Eigene Dateien\Visual Studio
> 2005\Projects\MDEDatenImport\MDEDatenImport\DataConnection.cs:Zeile
> 140.
>
> Was mache ich falsch?
>
> Gruß
> Dirk
>
Back to top
View user's profile Send private message
Dirk Michaelsen



Joined: 21 Dec 2007
Posts: 4

PostPosted: Mon Feb 11, 2008 12:01 pm    Post subject: Re: Indexerstellung_mit Reply with quote

I' very sorry. My fault was I made a crosspost to a German language
newsgroup. Wink

The problem is this: i wrote a C# application with Visual Studio 2005
Professional that creates a SQL Server Compact Edition database. The
database is copied to a smart device (Windows Mobile 5) after its
creation. Creating and filling of the database works like a charm but
unfortunately I'm unable to crate indexes on the tables.

I'm using the following code to create the indexes:

--- snip ---
private SqlCeConnection conn;
private SqlCeTransaction trans;

public void GenerateIndices()
{
Console.WriteLine("Creating indexes");
try
{
trans = conn.BeginTransaction();

string[] indexDefinitions =
{
"CREATE INDEX ArtstmId ON Artikel (artstm_id)",
"CREATE INDEX ArtikelNr ON Artikel (artikel_nr)",
"CREATE INDEX MestmId ON Mengeneinheiten (mestm_id)",
"CREATE INDEX ArtstmId ON Mengeneinheiten
(artstm_artstm_id)",
"CREATE INDEX MestmId ON Ean (mestm_mestm_id)",
"CREATE INDEX Ean ON Ean (ean)",
"CREATE INDEX MestmId ON Konditionen (mestm_mestm_id)"
};

foreach (string index in indexDefinitions)
{
Console.WriteLine("sending SQL-Command: " + index);
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = index;
cmd.ExecuteNonQuery(); // --> this is line 140
}
trans.Commit();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
--- snip ---

Already the first call of cmd.ExecuteNonQuery() leads to an exception
with the non-verbose message "[Artikel]" and this stacktrace:

---
$exception {" [ Artikel ]"} System.Exception
{System.Data.SqlServerCe.SqlCeException}
bei System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
bei
System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr&
pCursor, Boolean& isBaseTableCursor)
bei
System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior
behavior, String method, ResultSetOptions options)
bei System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
bei MDEDatenImport.DataConnection.GenerateIndices() in
C:\Dokumente
und Einstellungen\dimich\Eigene Dateien\Visual Studio
2005\Projects\MDEDatenImport\MDEDatenImport\DataConnection.cs:Zeile
140.
---

I don't know what I'm doing wrong. Consulting the MSDN documentation
this should work with SQL CE.

Can it be true that index creation is not possible with SQL CE
although MSDN claims it should be?

cu
Dirk
Back to top
View user's profile Send private message
Christopher Fairbairn



Joined: 08 Aug 2007
Posts: 19

PostPosted: Tue Feb 12, 2008 1:55 am    Post subject: Re:_Indexerstellung_mit_SQL_CE_nicht_möglich? Reply with quote

Hi,

"Dirk Michaelsen" wrote in message @4ax.com...
> Already the first call of cmd.ExecuteNonQuery() leads to an exception
> with the non-verbose message "[Artikel]" and this stacktrace:

The SqlCeException thrown should have a NativeError property. This error
code is important and will help clarify what is going on. If you search for
the NativeError code in a table such as the "Engine Errors" table available
at http://technet.microsoft.com/en-us/library/aa256772(SQL.80).aspx you
should hopefully get a better idea of what the problem is.

Hope this helps,
Christopher Fairbairn
Back to top
View user's profile Send private message
Dirk Michaelsen



Joined: 21 Dec 2007
Posts: 4

PostPosted: Mon Feb 11, 2008 7:50 pm    Post subject: Re: Indexerstellung_mit Reply with quote

Hi Christopher,

thanks for your reply but unfortunately the NativeError property is 0.

There are two other properties that look like error codes:

InnerException -> Static members -> Non-public-members ->
_COMPlusExceptionCode = -532459699

Non-public-members -> _HResult = -2146233087

Does that help any way?

Dirk Michaelsen

>The SqlCeException thrown should have a NativeError property. This error
>code is important and will help clarify what is going on. If you search for
>the NativeError code in a table such as the "Engine Errors" table available
>at http://technet.microsoft.com/en-us/library/aa256772(SQL.80).aspx you
>should hopefully get a better idea of what the problem is.
>
>Hope this helps,
>Christopher Fairbairn
Back to top
View user's profile Send private message
Dirk Michaelsen



Joined: 21 Dec 2007
Posts: 4

PostPosted: Mon Feb 11, 2008 8:20 pm    Post subject: Re: Indexerstellung_mit Reply with quote

It's me again Smile

I solved the problem.

The _HResult code led me to the problem that the DTC service was not
started on my computer. After starting the service I got another
exception with _HResult code -2147217856 wich means "the specified
table was in use".

I then tried to disconnect from the database after filling it with
data and reconnected before I started indexing. That worked.

Dirk Michaelsen

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
remote monitoring problem with WMI in C# Hello, I am using WMI with C# in order to monitorize the "name" of all the computers in a local net (LAN) and I don't know how can I make the query to get all the computers in the LAN: I don't know which WMI class must I use to store every computer inform

FileView.Net Control 8.0 released. [image: Sky Software is pleased to announce the release of FileView.Net Control 8.0 which brings a drop-in Windows Explorer-like listview UI to your application. It provides a familiar yet powerful file/folder

Datagri "Index was outside the bounds of the array datagrid" I've a datagrid filled with a collection of objects that inherits from When I remove an item from this collection and then click onto the datagrid, I've always this error: "Index was outside the bounds of the array datagrid" I've tried thi

Deploying Visio Viewer with my program Hello! I'm trying to deploy Visio Viewer with my program, and would very much like to embed the vviewrer.msi into the my msi-file. I've tried using Orca to make msm from the vviewer.msi file, and then merge it with my msi file, but without any luck. I'm u

SqlCacheDependency: recommended poll time? Hi, Untill we migrate to Sql Server 2000 we will be using in combination with Sql 2000. In this respect we should determine a poll frequency. i cannot find documentation that can help me in determining this setting. I am considering a
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> Compact Framework All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group