Last post May 19, 2009 08:04 AM by firstname.lastname@example.org
May 18, 2009 12:06 PM|young345|LINK
May 18, 2009 12:19 PMemail@example.com|LINK
can u pls elaborate it..like u have a textbox and u want to validate it against a value in database?? if this is the case.. u cn do the following... a) open up the connection to your database. b) query the database to get the desired value from the tables.
c) use if condition to check your textbox value to database value.
May 18, 2009 12:41 PM|young345|LINK
The value the user inputs … I want to be able to check if this value already exists in my database table. If the value exists there then I want it to throw an error. If the
value isn’t there the user can carry on.
Help on this would be much appreciated,
May 18, 2009 01:15 PM|CrazyChief|LINK
if you just need to send a query to your database then you could use something simple like:
SqlConnection lConnection = new SqlConnection("SERVER=(localhost);DATABASE=MyDB;UID=sa;PWD=xxx");
string lSqlGet = "SELECT COUNT (ID) FROM AnyTable";
SqlCommand lCommand = new SqlCommand(lSqlGet, lConnection);
int Count = (int)lCommand.ExecuteScalar();
catch (Exception ex)
//insert other error handling.
But it gets more complex and a little more complicated if you want to read whole tables, fill objects, etc.
So I would suggest you to take a look at ADO.Net, or better ADO.Net-Entity framework.
Besides that there a many nice technologies like LINQ or third party tools like subsonic.
May 18, 2009 01:40 PM|ashishksingh123|LINK
you can try this way:
1>First create connection from the database
2> use this way
this is a simple example: for password checking
LoginScreenDataSet.LoginentryDataTable dtloginscreen = dsloginscreen.Loginentry;
LoginScreenDataSet.LoginentryRow drloginscreen = dtloginscreen.NewLoginentryRow();
May 19, 2009 08:04 AMfirstname.lastname@example.org|LINK
string connectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=database name;Data Source=servername";
OleDbConnection cn = new OleDbConnection(connectionString);
OleDbCommand cm = new OleDbCommand("select [columnname] from [tablename] where colname='"+textbox1.Text+"'",cn);
rd = cm.ExecuteReader();
// throw an error
whatever u want to do