Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Select not working

Status
Not open for further replies.

patrickstrijdonck

Programmer
Jan 18, 2009
97
NL
Hi All,

Im very new to C#, trying to learn, but there is something i cant get to work, im sure im doing something wrong but i cant find what, little help in the good direction is very welcome :)

Code:
string constr = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\Patrick Strijdonck\Documents\IT4.mdb";
            string cmdstr = "SELECT Password = @textBox1 FROM tblGebruikers WHERE" + textBox1.Text;
    
            OleDbConnection con = new OleDbConnection(constr);
            OleDbCommand com = new OleDbCommand(cmdstr, con);
            con.Open();
            com.Parameters.Add("@textBox1", SqlDbType.VarChar);
            com.Parameters["@textBox1"].Value = name;
                                   
            con.Close();

What im trying to do, user fills in his name and password, and press sign on. then the SQL query shoud take a look at the table tblGebruikers and get that name and its password. put that password in a string and later(which is not in code) and if condition checks if String and textBox1.text are same, if so, continue, if not, cancel.

Hoping someone can help me ;)
 
parameterized queries are different than stored procs. stored procs are specific to sql server. oracle has them too but I don't know what they call them.

I don't use stored procs in my code. i use parameterized queries via an ORM framework.

@Patrick
it doesn't matter how big or small your project is. OOP will go a long way to keep your code clean, organized and maintainable.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top