473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ASP.NET connectivity from COM+

1
Hiya all,

I'm doing a project where the Web application of ASP.Net should refer to a COM+ program to retrieve and validate or insert data from/to SQL server.

The problem is - that it is not retrieving and validating the data even though I have added the COM+ program.

Just to explain what I'm saying, here's the code snippet:


Expand|Select|Wrap|Line Numbers
  1.     public class Login
  2.     {
  3.         SqlConnection con;
  4.         SqlCommand cmd;
  5.         SqlDataReader dr;
  6.         SqlTransaction sqltrans;
  7.  
  8.         public string selectAdmin(string cusername, string cpassword)
  9.         {
  10.             try
  11.             {
  12.                 con= new SqlConnection("server=localhost;user=sa;password=;database=Project");
  13.                 con.Open();
  14.                 sqltrans = con.BeginTransaction();
  15.                 cmd = new SqlCommand("SELECT cpassword FROM administrator WHERE cusername= "+cusername+"", con);
  16.                 cmd.Transaction=sqltrans;
  17.  
  18.                 dr=cmd.ExecuteReader();
  19.  
  20.                 dr.Read();
  21.  
  22.                 if (dr.Read()==false)
  23.                 {
  24.                     MessageBox.Show("'"+cusername+"' not found");
  25.                 }
  26.                 else 
  27.                 {
  28.                     if( dr.GetString(0) != cpassword.Trim())
  29.                     {
  30.                         MessageBox.Show("Password incorrect for '" + cusername + "'.");
  31.  
  32.                     }
  33.                 }
  34.  
  35.                 dr.Close();
  36.                 con.Close();
  37.  
  38.             }
  39.             catch(Exception)
  40.             {
  41.                 return "Exception Occurred";
  42.             }
  43.  
  44.             return "OK!";
  45.  
  46.         }
And here's the ASP program which should validate the data and redirect it to another page:

Expand|Select|Wrap|Line Numbers
  1. private void Button1_Click(object sender, System.EventArgs e)
  2.         {
  3.             string status="";
  4.  
  5.             string username=(user_textbox.Text).Trim();
  6.             string password=(pass_textbox.Text).Trim();
  7.  
  8.             string str;
  9.             Project.Login obj = new Project.Login();
  10.             str = obj.selectAdmin(user_textbox.Text, pass_textbox.Text);
  11.             lblmessage.Text=str;
  12.  
  13.             if (status=="OK!")
  14.             {
  15.                 Response.Redirect("AdminPage.aspx");
  16.  
  17.             }
  18.             else
  19.             {
  20.                 lblmessage.Text=status;
  21.             }
  22.  
  23.         }
  24.  
  25.         private void cancel_button_Click(object sender, System.EventArgs e)
  26.         {
  27.             Response.Redirect("Home.aspx");
  28.         }
  29.  
  30.     }
Where am I going wrong? It does not do anything whether I enter the correct or wrong username/password. It clears the password textbox but doesn't validate or show any message or error.

Please help.
Sep 13 '06 #1
0 1252

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Alex | last post by:
I have developed a VB application that uses Oracle 8i database for backend. The database server is on the local network. From my development machine, the application connects (via ODBC) to the...
2
by: Axel Dachtler | last post by:
I am looking for detailed information about the topic "connectivity" in Oracle 9i including JDBC and CGI. Thank you
1
by: harish | last post by:
I am using java applications to connect to my MS SQL Server database. I am using ODBC for database connectivity. If i am running my java applications in a remote PC and try to connect to database...
2
by: pengfrank | last post by:
I have a 500-MB full installation CD for SQL Server 2000. All I need is to install "Client Connectivity" component (about 272K) on a bunch of workstations for users across the nation. How do I...
3
by: Omegamon | last post by:
This one should be an easy one for the community. What sort of PC client software do I need for connectivity to a DB2 database? It appears DB2 Connect is special for PC/Unix Connectivity to...
3
by: junaid | last post by:
Hi to all, Can it is possible to connect to the databse like postgre or mysql through a C programm? I know the basics of C and I have developed a small program which uses a file for the...
3
by: Niks | last post by:
Hi, I need to connect to SQL server Database using a System DSN. Can anyone tell me how to connect to SQL Server using DSN in ASP.NET (VB.Net). Using a Try Catch block. Does anyone know how to...
1
by: Darren McDowell via .NET 247 | last post by:
I have a situation, I was wondering if someone could help me. Wehave a .net web service, it runs several transactions in sqlserver 2000. We have several clients which connect to this webservice in...
1
by: ohs | last post by:
Apologies for cross posting but I can't figure where to post. Please feel free to move my message elsewhere (notify mat<at>oldhallsoftware<.>com) cheers I have an ASP.net app that mobile...
3
by: DrinkyBanjo | last post by:
All I need to write a paper in my VB .NET class about the importance of the connectivity of VB to a database. Would you know of any websites to visit that would discuss this in detail? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.