Hi Folks,
I noticed a few similar posts, but for some reason I couldnt reply, so I have started afresh in IE not firefox.
Anyhoo!
My problem is with multiple database connectivity, I have a user login table and want to keep it seperate from the rest of my project, so in my program.cs file I have
Code:
1 static void Main()
2 {
3 // --- Manually register a connection (DO THIS ONE TIME ONLY) ---
4 esConnectionElement conn = new esConnectionElement();
5 conn.ConnectionString = @"Data Source=\program files\MetrolineNEW\dbMetroline.sdf";
6 conn.Name = "Metroline";
7 conn.Provider = "EntitySpaces.SqlClientProvider.Ce";
8 conn.ProviderClass = "DataProvider";
9 conn.SqlAccessType = esSqlAccessType.DynamicSQL;
10 conn.ProviderMetadataKey = "esDefault";
11 conn.DatabaseVersion = "2005";
12
13
14 esConnectionElement conn2 = new esConnectionElement();
15 conn2.ConnectionString = @"Data Source=\program files\MetrolineNEW\UserDetails.sdf";
16 conn2.Name = "UserDetailsConn";
17 conn2.Provider = "EntitySpaces.SqlClientProvider.Ce";
18 conn2.ProviderClass = "DataProvider";
19 conn2.SqlAccessType = esSqlAccessType.DynamicSQL;
20 conn2.ProviderMetadataKey = "esDefault";
21 conn2.DatabaseVersion = "2005";
22
23 // --- Assign the Default Connection ---
24
25 esConfigSettings.ConnectionInfo.Connections.Add(conn);
26 esConfigSettings.ConnectionInfo.Connections.Add(conn2);
27 esConfigSettings.ConnectionInfo.Default = "Metroline";
28
29 // --- Register the Loader ---
30
31 esProviderFactory.Factory = new EntitySpaces.LoaderMT.esDataProviderFactory();
Then in my code at the logon event I have:Code:
1 private void checkLogin(string _userName, string _password)
2 {
3 //Create a new instance of a user
4 BusinessObjects.TblUsers myUser = new BusinessObjects.TblUsers();
5 myUser.es.Connection.Name = "UserDetailsConn";
6
7 //load in details
8 try
9 {
10 //If there is a user there
11 if (myUser.LoadByPrimaryKey(_userName.Trim()))
12 {
13 _password = _password.Trim();
14 //if the pw matches
15 if (_password.CompareTo(myUser.Password) == 0)
16 {
17 authenticated = true;
18 }
19
20 else
21 {
22 //Bad pw
23 MessageBox.Show("Invalid Password");
24 }
25 }
26
27 else
28 {
29 //No user
30 MessageBox.Show("Invalid Username");
31 }
32 }
33
34 catch (Exception e)
35 {
36 MessageBox.Show("Login Error : " + e.Message);
37 }
38 }
But for some reasson it keeps jumping out at the
//If there is a user there
if (myUser.LoadByPrimaryKey(_userName.Trim()))
Line and throwing an error message even if there is a valid name....
Any ideas? It seems that the es query is always returning null