Hello guys!i am kinda new to C# and i am just learning....the thing is..i want to make a little app.I made something like a login form with a username and password textbox.i need these textboxes to go into the acces database(which i succesfully added to the project and all it works fairly well,i tried the grid view and stuff..) and u know..like search a certain column ..check if the string in the username textbox is found in the username column from the acces database,if so..i need it to check if the text from the password textbox coresponds to the password on the same line in the password column. ..u udnerstand..a login form,using an acces database.,,

Actually!!!the thing i am asking is how do i acces data on..i dont know on a certain column or a certain line...the sintax..i can manage a simple algorythm that searches the database..i jsut need the sintax..like how do i make it acces u know..like in excel ...cell A,row 2.. u get it..i cant find this anywhere on the internet and i really need this..any ideas please?or if you dont know how to use acces(i know its not really that used) i beg you guys to help me in mysql or sumthing..i have been googling for 2 days and i feel like i am going insane!

Recommended Answers

All 7 Replies

Then you've to read in Introduction to OLE DB http://www.functionx.com/vbnet/oledb/Lesson01.htm

I think that's in visual basic..cause tthe sintax seems different...could someone just simply tell me..how do i connect to my databse,how i can get a value from ..i dont know..column 3,row 2 or something like that? i need to manipulate the databse....from the coding...i wanna make a login form...HELP?!?

Buddy! If I showed you some codes you'd drop million of questions! here we don't say how to develop an application, here we help if you face some problem, as because you're not familiar with ADO.NET anything answered here is valueless!!

i understand man...but i just need those things if you could help me..i have been researching and i cant find anything.. iusually hate asking on forums just because people go and just rant on you..jsut please give me some good reference on this..on a tutorial with an example of sumthing like this..i dont know..i just need to acces those certai nrows and columns...i need the sintax..u know..like Form1 f1 = new Form2(); f1.Show(); to open a new form..jsut give me those words that will give me the data:D Please!

OK! As you like...
This code untested please adjust your variables to fit your case.

private const string CONNECTION_STRING =
            @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=[access database file path];Persist Security Info=False;";

        public bool CheckValidUser(string username, string password)
        {
            OleDbConnection dbConnection = new OleDbConnection(CONNECTION_STRING);
            
            string commandString = 
            "select count(*) from users where username = @username and password = @password";
            
            OleDbCommand commandStatement = new OleDbCommand(commandString, dbConnection);
            
            commandStatement.Parameters.Add("@username", OleDbType.VarWChar).Value = username;
            commandStatement.Parameters.Add("@password", OleDbType.VarWChar).Value = password;
            
            dbConnection.Open();
            int x = (int)commandStatement.ExecuteScalar();
return true ? x > 0 : false;
        }

the only thing i dnt get is

int x = (int)commandStatement.ExecuteScalar();
return true ? x > 0 : false;
        }

whats with the scalar?i didnt try all this yet..but this part bums me out

Move your mouse on ExecuteScalar and see what the tooltip shows.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.