Database explorer

G

Guy Cohen

Hi all.

What is the use of this window?
Is it only to see the objects/tables of the database?

Lets say I have this code:


Dim SQL As String
SQL = "SELECT * from mytable"

Dim Adapter As New Data.OleDb.OleDbDataAdapter(SQL, connection )

Dim DS As New Data.DataSet

Call Adapter.Fill(DS)

Can I use connection from the database explorer window instead of providing
a connection string ?

I am using this code on several .aspx pages - should I use dim
connectionstring as string in each of them?

Where do I put a global parameter/constant ?



Newbie me....

TIA

Guy
 
M

Mark Rae

I am using this code on several .aspx pages - should I use dim
connectionstring as string in each of them?

Where do I put a global parameter/constant ?

Newbie me....

Do yourself a *HUGE* favour and steer well clear of all the new "make it
easy for people who don't know how to write code" database access controls
in ASP.NET 2, and use a DAL (database abstraction layer) instead.

This will get you started, but ultimately you will want to write your own:
http://aspnet.4guysfromrolla.com/articles/070203-1.aspx
 
G

Guy Cohen

Thanks again Mark.

My problem is that my boss wants the fastest solution from me and I am not
familiar with do(n)t net *blush*

Guy
 
M

Mark Rae

My problem is that my boss wants the fastest solution from me and I am not
familiar with do(n)t net *blush*

Believe me, once you have all the base classes in place, this is by far the
best method of rapid robust development.

E.g. here's a basic GridView control:

<asp:GridView ID="MyGridView" runat="server">
...bound fields etc
</asp:GridView>

Let's say I have a stored procedure called "MyStoredProcedure" which returns
the data I need to populate the GridView. With my DAL, this is how it gets
populated:

MyGridView.DataSource = DAL.GetDataSet("MyStoredProcedure");
MyGridView.DataBind();

That't it! Because the DAL is a public class and the GetDataSet method (like
all the others) are static, nothing further is required. Any page in the web
app which needs database connectivity just calls one of the methods in the
DAL. GetDataSet, as its name suggests, returns a DataSet object. Other
methods in the DAL return an SqlDataReader, others perform database writes,
others wrap stuff in transactions, others work with binary data etc.

Of course, the methods in the DAL are overloaded to accept a different
connection string from the default one (which is stored encrypted in
web.config), and also a List<SqlParameter> generic collection to support
parameterised stored procedures.

A relatively small investment in time and effort to set your base classes up
will allow you to whizz through the rest of the development cycle.

Where are you based, AAMOI...?
 
G

Guy Cohen

Mark you are great!

Guy @ Israel


Mark Rae said:
Believe me, once you have all the base classes in place, this is by far
the best method of rapid robust development.

E.g. here's a basic GridView control:

<asp:GridView ID="MyGridView" runat="server">
...bound fields etc
</asp:GridView>

Let's say I have a stored procedure called "MyStoredProcedure" which
returns the data I need to populate the GridView. With my DAL, this is how
it gets populated:

MyGridView.DataSource = DAL.GetDataSet("MyStoredProcedure");
MyGridView.DataBind();

That't it! Because the DAL is a public class and the GetDataSet method
(like all the others) are static, nothing further is required. Any page in
the web app which needs database connectivity just calls one of the
methods in the DAL. GetDataSet, as its name suggests, returns a DataSet
object. Other methods in the DAL return an SqlDataReader, others perform
database writes, others wrap stuff in transactions, others work with
binary data etc.

Of course, the methods in the DAL are overloaded to accept a different
connection string from the default one (which is stored encrypted in
web.config), and also a List<SqlParameter> generic collection to support
parameterised stored procedures.

A relatively small investment in time and effort to set your base classes
up will allow you to whizz through the rest of the development cycle.

Where are you based, AAMOI...?
 
E

Edwin Knoppert

Thanks, i have often an issue with paramters and such.
Hopefully this code can handle paging.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top