Checking for records in two different db?

Results 1 to 2 of 2

Thread: Checking for records in two different db?

  1. #1
    Join Date
    Dec 1969

    Default Checking for records in two different db?

    Hello,<BR><BR>I was wondering is there a way I can check the value of a users input with two different databases. I have a login screen where the user logs in and I have it checking a database that contains the userID&#039;s and passwords and if the user exists It allows them to login, but what I want to do next is if the user exists I would like the usersID checked against another database to see if the user exists in that database if they do give them a message stating. "Form was already completed" How would I go about doing that? Can I have two SELECT statments just have them pointing to the two different databases? Or can this even be accomplished? This is the code I have for my login screen<BR><BR>public String RedirectPage="Demo.aspx?";<BR> public int chk;<BR> <BR> bool Authenticate(string user, string pass)<BR> {<BR> bool authenticated = false;<BR> try<BR> {<BR> string connectionString="Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=C:\Inetpub\wwwroot\DEMO1\Login.mdb";<BR> //string connectionString="Provider=Microsoft.Jet.OLEDB.4.0 ;Password="";User ID=Admin;Data Source=E:OTC_TESA WebEventDatabasesabcsLogin.mdb"; <BR> OleDbConnection myConnection = new OleDbConnection( connectionString);<BR> myConnection.Open();<BR> string sSQL="SELECT Login,Password1 FROM LOGIN_TABLE WHERE Login=&#039;"+user.Trim()+"&#039; AND Password1=&#039;"+pass.Trim()+"&#039;";<BR> OleDbCommand myCommand = new OleDbCommand(sSQL,myConnection);<BR> OleDbDataReader Read1=null;<BR> Read1 = myCommand.ExecuteReader();<BR> myCommand.CommandText = sSQL;<BR> myCommand.Connection = myConnection;<BR> //myCommand.ExecuteNonQuery();<BR> Read1.Read();<BR> //SqlConnection conn = new SqlConnection(connectionString);<BR> //SqlCommand cmd = new SqlCommand(sSQL,conn);<BR> //SqlDataReader Read1=null;<BR> //conn.Open();<BR> //Read1 = cmd.ExecuteReader();<BR> //Read1.Read();<BR> if (Read1!=null)<BR> {<BR> if (Read1.GetString(0) == user)<BR> {<BR> if (Read1.GetString(1)==pass)<BR> {<BR> authenticated = true;<BR> }<BR> else<BR> {<BR> chk=1;<BR> }<BR> }<BR> else<BR> {<BR> chk=2;<BR> }<BR> }<BR> }<BR> catch<BR> { <BR> return false; <BR> } <BR><BR><BR> return authenticated;<BR> } <BR> <BR> private void LogInBtn_Click(object sender, System.EventArgs e)<BR> {<BR> if (Authenticate(LoginID.Text, LogInPassword.Text)) <BR> { <BR> Response.Redirect(RedirectPage); <BR> } <BR> else<BR> { <BR> Message.Text="UserId or PassWord Invalid"; <BR> Message.Visible=true;<BR> <BR> }<BR> }<BR> <BR> private void PasswordBtn_Click(object sender, System.EventArgs e)<BR> {<BR> Response.Redirect("CreatePassword.aspx?");<BR> }<BR><BR>This checks the users input against the LOGIN.mdb I have to check and see if the user exists and has a password. I would like to check another database to make sure if the user exists in that as well. How can I go about doing that?

  2. #2
    Join Date
    Dec 1969

    Default RE: Checking for records in two different db?

    Just create a 2nd database connection and execute your query against that...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts