Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. using System;
  2. using Gtk;
  3. using Mono.Data.Sqlite;
  4. using System.Data;
  5.  
  6. namespace BB
  7. {
  8. public partial class BBLogin : Gtk.Window
  9. {
  10. public BBLogin () :
  11. base (Gtk.WindowType.Toplevel)
  12. {
  13. this.Build ();
  14. }
  15.  
  16. private void btnLoginOnClick (object sender, EventArgs e)
  17. {
  18. SqliteConnection conn = new SqliteConnection();
  19. conn.ConnectionString = "Data Source=BBUser.sqlite;Version=3;";
  20. SqliteCommand command = new SqliteCommand();
  21. command.CommandText = ("SELECT UserName FROM T_test WHERE UserName=@UserName AND Password=@Password");
  22. command.Parameters.AddWithValue ("@UserName", txtUserName.Text);
  23. command.Parameters.AddWithValue ("@Password", txtPassword.Text);
  24.  
  25. conn.Open ();
  26. SqliteConnection.CreateFile("failsafe0.sqlite");
  27. object result = command.ExecuteScalar();
  28. SqliteConnection.CreateFile("failsafe1.sqlite");
  29. conn.Close ();
  30. SqliteConnection.CreateFile("failsafe2.sqlite");
  31. string userNameLogin = Convert.ToString(result);
  32. SqliteConnection.CreateFile("failsafe3.sqlite");
  33.  
  34. if (userNameLogin != "")
  35. {
  36. SqliteConnection.CreateFile("success.sqlite");
  37. /*MessageDialog md = new MessageDialog ("Username was correct!");
  38. md.Run ();
  39. md.Destroy();*/
  40. }
  41. else
  42. {
  43. SqliteConnection.CreateFile("failed.sqlite");
  44. /*MessageDialog md = new MessageDialog ("Username or password is incorrect!");
  45. md.Run ();
  46. md.Destroy();*/
  47. }
  48. }
  49.  
  50. }
  51. }
  52.  
  53. Exception in Gtk# callback delegate
  54. Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
  55. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: No connection associated with this command
  56. at Mono.Data.Sqlite.SqliteCommand.InitializeForReader () [0x00000] in <filename unknown>:0
  57. at Mono.Data.Sqlite.SqliteCommand.ExecuteReader (CommandBehavior behavior) [0x00000] in <filename unknown>:0
  58. at Mono.Data.Sqlite.SqliteCommand.ExecuteScalar () [0x00000] in <filename unknown>:0
  59. at BB.BBLogin.btnLoginOnClick (System.Object sender, System.EventArgs e) [0x0006c] in /home/christian/BB/BB/BBLogin.cs:27
  60. at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  61. at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  62. --- End of inner exception stack trace ---
  63. at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  64. at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
  65. at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0
  66. at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0
  67. at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <filename unknown>:0
  68. at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
  69. at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
  70. at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x00000] in <filename unknown>:0
  71. at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e, Boolean is_terminal)
  72. at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
  73. at Gtk.Application.gtk_main()
  74. at Gtk.Application.Run()
  75. at BB.MainClass.Main(System.String[] args) in /home/christian/BB/BB /Program.cs:line 15
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement