Groups > Databases > Oracle for ASP.NET > Re: How to create a connection between oracle database and the webform




How to create a connection between oracle database and the
webform

How to create a connection between oracle database and the webform
Fri, 28 Mar 2008 06:15:22 +000
hi, is anyone here possible to teach me how to connect Oracle  database to my
webform?
Post Reply
Re: How to create a connection between oracle database and the webform
Fri, 28 Mar 2008 07:14:21 +000
To connect to an Oracle database using OraOLEDB, the OLE DB connection string
must be as follows: 

"Provider=OraOLEDB.Oracle;Data Source=R2D2;User ID=foo;
Password=bar";
						

Make sure that you have entry for the data source in tnsnames.ora file and
TNSListener service is running. For more information on OraOLEDB provider refer
to Orcale9i documentation. 

And as an example code try this

private bool ValidateUser(string strLogin, string strPwd)
{
bool bRet = false;
OleDbConnection conn = null;
try
{
string connString = "Provider=OraOLEDB.Oracle;Data Source=R2D2;User
ID=foo;Password=bar";
conn = new OleDbConnection(connString);
conn.Open();
string strQuery = "select * from siteusers where login='" + strLogin +
"'";
OleDbCommand obCmd = new OleDbCommand(strQuery, conn);
OleDbDataReader obReader = obCmd.ExecuteReader();
while (obReader.Read())
{
string strVal = obReader["password"].ToString();
if (string.Compare(strVal, strPwd) == 0)
{
bRet = true;
}
}
}
catch (OleDbException ex)
{
Response.Write(ex.Message);
throw ex;
}
finally
{
if (null != conn)
{
conn.Close();
}
}
return bRet;
}
Post Reply
Re: How to create a connection between oracle database and the webform
Fri, 28 Mar 2008 07:20:48 +000
wat to type for the namespace.. and wat is try ,  catch , throw , finally use
for??
Post Reply
Re: How to create a connection between oracle database and the webform
Fri, 28 Mar 2008 07:36:50 +000
The namespace you have to include is:

using System.Data.OracleClient;

Hope it worked!
Post Reply
Re: How to create a connection between oracle database and the webform
Fri, 28 Mar 2008 07:52:31 +000
visit: http://www.connectionstrings.com/?carrier=oracle 

u will surely get a solution
Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact