2 Replies - 465 Views - Last Post: 20 January 2010 - 07:26 AM Rate Topic: -----

#1 Rpgdudester  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 11-January 10

mySQL and C#

Posted 20 January 2010 - 05:48 AM

hey guys, i'm back with another confusing question:

I have this:

public DataSet DoSql(String SqlStatement)
		{
			DataSet myDS = new DataSet();
			MySql.Data.MySqlClient.MySqlDataAdapter myAdapter;
			MySql.Data.MySqlClient.MySqlCommand cmd;

			cmd = new MySql.Data.MySqlClient.MySqlCommand();
			myAdapter = new MySql.Data.MySqlClient.MySqlDataAdapter();

			cmd.CommandText = SqlStatement;
			cmd.Connection = connection;

			myAdapter.SelectCommand = cmd;
			myAdapter.Fill(myDS);

			return myDS;
		}


which is ok, but now i have a problem as to how to actually get it to work, I tried this:

 DataSet username;
username = DB.DoSql("SELECT Username,Password FROM players");


and then tried to compare that to my user's input here:

 if (input.ToLower() == username) 
but it keeps giving me a "Error Operator '==' cannot be applied to operands of type 'string' and 'System.Data.DataSet' " and i'm not sure how to get it to work

any ideas or suggestions?

Is This A Good Question/Topic? 0
  • +

Replies To: mySQL and C#

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: mySQL and C#

Posted 20 January 2010 - 06:11 AM

Look at your query. You are returning EVERY username and password pair in the database table. You will need to loop through the dataset to compare.

You can't compare a string to a dataset. They are different types that have no relation to each other.
Was This Post Helpful? 0
  • +
  • -

#3 megabuh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 19-January 10

Re: mySQL and C#

Posted 20 January 2010 - 07:26 AM

You must parse your sql result. Then you can use IF condition to compare every result from your sql query.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1