Sorry for the reason of any inconvenience.
Asking about databases or databanking instead
My window looks like this:
The Browse button looks at "My network place"
Browse private zags (object sender, routing events, E) {folderbrowser dialog dialog = new folderbrowserize (); Type t = dialog.GetType (); System.Reflection.FieldInfo fi = t.GetField ("rootfolder", system. Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); Fietset (Dialogue, 0x0012); Dialog.ShowDialog (); Dialog.ShowDialog (); String selected = dialog Chosen path; Computertext.Text = Dialogues Chosen path; } So now my computer text. Text pass information, for example: Computer 1
To log in now, I have to check whether computer text is information or not, under which user name and password I already use a Microsoft Access The database has been created that looks like this ...
id computer name login id password 1 computer 1 com 1 123456 2 computer 2 com 2 234567 I almost type command for loginBtn Not ...
private void Loginbitian_klik (object sender, routing Aventarj e) {// if computerText.Text == data My Detasrs [Computername] & amp; ; LoginName.Text == My data source data [loginID] & amp; Amp; password. Text == My datasource data [password] {loginStatus.Text = "login success!"; } Else {loginStatus.Text = "Login failed!"; } So my question is:
1) How to tie my database now?
2) How to code above
Renamed has the following code:
Private Wide Longbutton_Link (Object Sender, Routing Avenger, ARGs E) {Allback Connection Con; Ondebee Comand Com; OlebeyDiDaderDr; Conn = new OleDbConnection ("Provider = Microsoft .ACE.OLEDB.12.0; Data Source = | Data Directory | / Database 1. ACCdb"); Com = New Oleadby Comand ("Select from Remote where loginId = @ id and password = @ pass", Con); Comm.parameters.Add (New OleDbParameter ("@ ID", System.Data.oleDbType.NVarChar, 20, "loginID")); com. Parameter. Add (New Alternate Piperator ("Pass @", System.doly.doly.b.worker, 20, "password")); Conn.Open (); Dr = comm.ExecuteReader (); Conn.Close (); If (Dr. HSRO) {loginStatus.Text = "Login successfully"; } Else {loginStatus.Text = "Login failed!"; String message = "Wrong username / password entered!"; String caption = "alert!"; Message box button button = message box Oak; Message box image icon = message box image. Warning; System.Windows.MessageBox.Show (message, captions, buttons, icons); }} Prompt error: "The name or name of the name 'ole debe type' is not present in the namespace 'System.Data' (are you missing an assembly reference?)" P>
and if I remove System.Data.oleDbType.Nararhar, 20, it works perfectly, but when I type in my user name and password according to my database, I get the signal That login failed .. EG:
Computer name: Computer1 username: com1 Word: 123456fMay something like that, create a connection and read from your access file .
OleDbConnection conn; Ondebee Comand Com; OlebeyDiDaderDr; Conn = new OleDbConnection ("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C: \\ db1.mdb"); Com = new OLDB Commands ("Select 1 to Table 1, where loginId = @ id and password = @ pass", Con?); Comm.parameters.Add (New OleDbParameter ("@ ID", System.Data.oleDbType.NVarChar, 20, "loginID")); com. Parameter. Add (New Alternate Piperator ("Pass @", System.doly.doly.b.worker, 20, "password")); Conn.Open (); Dr = comm.ExecuteReader (); Conn.Close (); If you can authenticate against user input using dr then {// login success} and // login failedby its line of comments Keep Up.
Comments
Post a Comment