Wednesday, August 18, 2010

Visual Basic help!?




I have a bit of a problem with Visual Basic here. I'm basically working with a database that displays bikes for a company which has a number of different bike dealers. I need to design the site like this - the dealer signs in on the front page with their unique password given to them (I have the passwords in a database) and the GridView (or maybe something else would be better?) should display only that particular dealer's bikes. Now, this is the tricky part because I have no idea how to achieve that, neither by means of an SQL query nor VB codebehind. Answers would be very much obliged.





NSVisual Basic help!?
Depends on how your database is build. But lets assume you have the password database with something like password_db(key number, password text, for_id number). Now the for id is the id of the byke company. Now you have a second DB which has the companies more or less this structure: byke_companies(key number, name text) now you have the third which have the bikes bikes(key number, bikename text, bykeprice number, for_id number). Now the for_id of both tables are the byke_companies key. So to Select in SQL SELECT * FROM bikes WHERE bikes.for_id = (SELECT for_id FROM password_db WHERE password = 'thepassword') thepassword you have to catch from a field, don't forgett protection, meaning passwordsave your database, make the passwords be a MD5 checksum or something like that, do never store passwords in plaintext. If you do it in a mdb file you should make sure that they cannot open it without password, even if they press ';shift'; and then ';open';. In VB you can run Queries with this command DoCmd.RunSQL (query). If you want a resultset you need following command


Set dbVOA = CurrentDb


Set rstName = dbVOA.OpenRecordset(query)


the rstName is a resultset. Google for that for further information about how to handle this.

No comments:

Post a Comment