Friday, September 22, 2006

accessdatasource - how to use

General information
the accessdatasource code use to login to a accses (there are anther code to login to anther databace, like sql sever).
How to use
to use accessdatasource we write this code:

<asp:accessdatasource id="AccessDataSource8" selectcommand="SELECT 4 * FROM [bla] WHERE ([bla] = ?) ORDER BY [id] DESC" datafile="db.mdb" runat="server">


and this are the parameters we use -
id - the id of the accessdatasource
runat - we need to write it in all the asp.net codes we use
datafile - the accses mdb file we use
selectcommand - the sql code. you can see a good bonus we got in the WHERE
- the ? we use in the sql ([cla] = ?)
- a request.querystring for the ? in the sql. you can see the name = "bla" amd the QuerystringField = "site". site is the request.querystrung paramater we use, its do somethin like this - request.querystring("site"). if the url are bla.asp?site=aa the ? was aa.

Anther things like QuerystringParamater
you can do anther things like QuerystringParamater, but not wite request.querystring.

it use a cookie.
<asp:CookieParameter Type="String" Name="site" CookieName="sesshhfgh"></asp:CookieParameter>
it use a session.
<asp:SessionParameter SessionField="sdf" Type="String" Name="site2"></asp:SessionParameter>
Use the accessdatasource with repater, datagrid and more.
to use the accessdatasource in a repater,datagrid or anther, we use this code -
datasourceid="AccessDataSource8"
and AccessDataSource8 was the id of the accessdatasource.
you add it to the code like this -

and it work.

Succses!





No comments: