Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB Connectivity » View Thread |
Messages 1 to 10 of 11 total |
Trouble in .Net land |
Mon, Jul 4 2016 6:45 AM | Permanent Link |
Matthew Jones | Okay, fundamentally things are fine - I used the database connection
thing in Visual Studio to connect to the database and it works fine. So I want to check things are set up properly on starting. I copied the sample code so I could check that the databases are there, but it comes up with the same error as the EDB Manager does if you don't select a session. The various posts here say that the session is now integrated with the connection, but how do I make it work? The connection string obviously works when the rest of .Net uses it for a connection. I also want to know if there is no catalog at all, but I was going to assume that an exception somewhere indicated that, and pop the appropriate master files in place if not present. var DataConnection = new global::Elevate.ElevateDB.Data.EDBConnection(); DataConnection.ConnectionString = EDBConnection.SettingsAccess.DBConnectString; DataConnection.Open(); EDBCommand DataCommand = new EDBCommand(); DataCommand.Connection = DataConnection; // Check to see if the database exists or whether it needs to be created DataCommand.CommandText = "SELECT * FROM Databases"; // " WHERE Name='StoreName'"; if (DataCommand.Execute() == 0) { // fails with an exception: {"ElevateDB Error #700 An error was found in the statement at line 1 and column 15 (ElevateDB Error #401 The table or view Databases does not exist in the schema Default)"} The config string it built was (modified to change app name and passwords) name=New;charset=Unicode;type=Local;configmemory=False;temppath=C:\MyDat a\Temp;largefiles=False;standardnull=True;cataloginfo=True;cachemodules= False;configname=EDBConfig;configext=.EDBCfg;lockext=.EDBLck;logext=.EDB Log;maxlogsize=1048576;logcats=Info,Warn,Error;catalogname=EDBDatabase;c atalogext=.EDBCat;backupext=.EDBBkp;updateext=.EDBUpd;tableext=.EDBTbl;i ndexext=.EDBIdx;blobext=.EDBBlb;publishext=.EDBPbl;uid=MyApp;pwd=snip;da tabase=MyDatabase;readonly=False;rowlockprotocol=Pessimistic;rowlockretr ies=15;rowlockwait=100;detectrowchanges=False;flushwrites=False;keeptabl esopen=False;address=127.0.0.1;port=12010;connecttimeout=15;ping=False;p inginterval=60;timeout=180;encrypted=False;encryptsrvpwd=elevatesoft;com pression=0;trace=False;signature=MySignature;encryptpwd=snip;configpath= C:\MyData |
Mon, Jul 4 2016 6:52 AM | Permanent Link |
Matthew Jones | Matthew Jones wrote:
> Trouble in .Net land To be clear, it is my trouble based on inexperience, not actually anything to do with EDB! I just read the heading and realised it sounded bad. It is MY trouble, not anything else! D'oh! (On the other hand, click-bait might get me the answer. 8-) |
Tue, Jul 5 2016 7:29 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Matthew,
What you want is the ChangeDatabase method, which is a common DBConnection method. You would use it like this: private void button1_Click(object sender, EventArgs e) { EDBConnection DataConnection = new EDBConnection(@"NAME=Test;DESCRIPTION=Test Connection;TYPE=LOCAL;CONFIGPATH=C:\Unicode;DATABASE=ADOUnicodeTest;UID=Administrator;PWD=EDBDefault"); DataConnection.Open(); DataConnection.ChangeDatabase("Configuration"); EDBCommand DataCommand = new EDBCommand(); DataCommand.Connection = DataConnection; // Alter the database path DataCommand.CommandText = @"ALTER DATABASE ADOUnicodeTest PATH 'c:\newpath\data'"; DataCommand.ExecuteNonQuery(); DataConnection.ChangeDatabase("ADOUnicodeTest"); DataConnection.Close(); } Tim Young Elevate Software www.elevatesoft.com |
Tue, Jul 5 2016 10:46 AM | Permanent Link |
Matthew Jones | Tim Young [Elevate Software] wrote:
> DataConnection.ChangeDatabase("Configuration"); Hmm, this allows it to run the query without error, but it doesn't find the database that is there (but in the other session config). Thus it tries to create the new database, but can't as it isn't set up - I get this error: "The database Configuration is read-only and this operation cannot be performed (CREATE TABLE StoreName)" The table does exist, but in the EWB Manager it is not the default session. I need to connect to that session somehow. I can't see how the ..net DataStore code is doing it, but it is... To be clear, all the data is there, I just need to connect to it to make sure it is there. If it isn't then I will do the setup. |
Wed, Jul 6 2016 7:31 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Matthew,
<< Hmm, this allows it to run the query without error, but it doesn't find the database that is there (but in the other session config). >> What "other session config" are you referring to ? You can't access another configuration within the same connection. As far as you're concerned, coming from VCL components, a connection=session+database. << Thus it tries to create the new database, but can't as it isn't set up - I get this error: >> Make sure to call ChangeDatabase to change *back* to the normal, non-Configuration database before trying to execute any database-level operations. Tim Young Elevate Software www.elevatesoft.com |
Wed, Jul 6 2016 9:31 AM | Permanent Link |
Matthew Jones | Tim Young [Elevate Software] wrote:
> << Hmm, this allows it to run the query without error, but it doesn't > find the database that is there (but in the other session config). >> > > What "other session config" are you referring to ? You can't access > another configuration within the same connection. As far as you're > concerned, coming from VCL components, a connection=session+database. > > << Thus it tries to create the new database, but can't as it isn't > set up - I get this error: >> > > Make sure to call ChangeDatabase to change back to the normal, > non-Configuration database before trying to execute any > database-level operations. Forgive my confusion - in my first reply to your message I realised that the connection string contains a "database" and in the sample at http://www.elevatesoft.com/articles?action=view&category=edb&article=deploying_elevatedb_applications you have it contain database=Configuration which explains why I had to add the ChangeDatabase call. However, the code I'm wanting to run is indeed the code in that sample, to check things are set up properly, and create the tables if they don't exist. However, they *do* exist and the DataCommand.CommandText = "SELECT * FROM Databases WHERE Name='StoreName'"; if (DataCommand.Execute() == 0) is going into the code to create the database, yet it does exist, so should not. So either it is not looking in the right place, or it isn't the right way to test for the result. Basically, I can't get the sample code to work for my database. Thanks for your help, Matthew |
Thu, Jul 7 2016 7:53 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Matthew,
<< However, the code I'm wanting to run is indeed the code in that sample, to check things are set up properly, and create the tables if they don't exist. However, they *do* exist and the >> Please post the code that you're using. Tim Young Elevate Software www.elevatesoft.com |
Thu, Jul 7 2016 8:39 AM | Permanent Link |
Matthew Jones | Tim Young [Elevate Software] wrote:
> Please post the code that you're using. See the original post. |
Fri, Jul 8 2016 5:52 AM | Permanent Link |
Matthew Jones | Ignore me - this is my lack of understanding of the structure.
Basically, it is getting the DATABASE but that is not the TABLES which come from the Information.Tables area. One thing that I think is lacking is an example of how to get the data from the command cursor. I managed to work out this: var cursor = DataCommand.ExecuteCursor(); cursor.ReadFirst(); while (!cursor.EOF) { for (var index = 0; index < cursor.FieldCount; index++) { Console.WriteLine(cursor[index].ToString()); } cursor.Read(); } But no idea what the field names are that match them. In Delphi I'd use myQuery.FieldByName("MyField").AsString or similar. Is there an equivalent for .Net and C#? |
Fri, Jul 8 2016 6:08 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Matthew,
<< One thing that I think is lacking is an example of how to get the data from the command cursor. I managed to work out this: >> EDBDataCursor is a descendant of the DataReader class, so it works in the same way, minus the uni-directional aspect (DataCursor is a bi-directional cursor): http://www.elevatesoft.com/manual?action=viewtopic&id=edb2dac&topic=EDBDataReader EDBDataReader is also a descendant of the DbDataReader class, where most of the common functionality is located: https://msdn.microsoft.com/en-us/library/system.data.common.dbdatareader(v=vs.110).aspx Tim Young Elevate Software www.elevatesoft.com |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Monday, April 29, 2024 at 05:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |