Moving to ASP.Net from ColdFusion -- connecting to a database???

A

Alex

Hi all,

I've been writing in ColdFusion for about 6 years now, and now that
we've installed a Sharepoint Portal Server I'm finding that I need to
use ASP.Net to make database calls. I'm finding no good documentation
for someone who hasn't worked with ASP.Net...

In ColdFusion it's a very simple task to pull data from a database...
just setup the datasource in the CF Admin page and use something like
this:

<cfquery name="GetData" datasource="MyDS">
select Firstname, Lastname from Names
</cfquery>

<cfoutput query="GetData">
#Firstname# #lastname#<br>
</cfoutput>

But when I try to see how to do this in ASP.Net I found this page on
MS's website: http://tinyurl.com/9vk2c

And without even giving any code examples here's what it says:

To access SQL databases from ASP.NET
1. Create a database connection using the SqlConnection class.
2. Select a set of records from the database using the
SqlDataAdapter class.
3. Fill a new DataSet using the SqlDataAdapter class.
4. If you are selecting data from a database for non-interactive
display only, it is recommended that you use a read-only, forward-only
SqlDataReader (or OleDbDataReader for non-SQL databases) for best
performance. When using a SqlDataReader, select the records using a
SqlCommand query and create a SqlDataReader that is returned from the
SqlCommand object's ExecuteReader method.

In some cases, such as when you want to sort or filter a set of
data, you might also want to create a new DataView based on a DataSet
for the desired table.
5. Bind a server control, such as a DataGrid, to the DataSet,
SqlDataReader, or DataView.

Why is everything Microsoft touches so freakin' complicated? Is there
not some sample code I can use that I can simply change my database
name, server, and login info then create some loop to cycle through my
data? I'm not writing an entire application, just making a call to a
database to show on the screen via a DWP page.. I've stayed away from
Microsoft's programming languages thus far because they are so bloated
compared to CF, PHP, and even standard C++ when talking about app
development, but now I'm finding I have to use ASP.Net or similar to
create database requests with SPS. Am I wrong? Is it simpler them
MS's tech docs show it to be? Do I need to get a Masters in CS to
learn this mess?

Thanks for any comments or suggestions... it's gotta be simpler then
this!

Sam Alex
 
T

tom pester

Hi Alex,

I don't master CF but I think you are correct that ASP.NET requires more
code and more 'mental model'.

I also read posts that say ASP.NET with its controls (that tend to go toward
things you are doing in CF) are too simple and inflexible.
These guys want to do everything on a lower level.

Then there are people who want to do everyting as declative as possible (CF
programmers fall into this category I presume) and sigh with every extra
line of code they think isn't necessary.
It isn't necessary as long as the problem you are trying to solve is general
enough (the majority of the cases IMO).

ASP.NET is trying to place itslef between these 2 approaches and tries to
give the best of both worlds. In the old classic asp days you woul have even
more sighed :)

Check out this tutorial if you still want to bite the bullet :
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

The first part will get you started and the rest of the chapters will show
you more datagrid power.


Cheers,
Tom Pester
 
S

Sam ALex

Hi Tom,

I apologize for my initial email being so tactful, but I get frustrated
when working with Microsoft languages and using their online help. The
URL you sited helps, and I think that's a great starting point, so
thanks a million for that!

Basically in a nutshell what I've written over the last 6+ years in
ColdFusion is a content management and document management system for
our Intranet, and though it works rather well, SPS has some features we
like... like being integrated into MS Office, Exchange, and Active
Directory. The only problem is we have so many custom 'dashboards' and
applications I've created in ColdFusion that it'll take time to
transpose these to ASP.Net (or whatever language is needed on SPS).

You're right in that CF and ASP.Net are on two ends of the spectrum, and
with me knowing PHP as well I can see how having more options is
helpful... but MS doesn't help much when someone like me who has
experience programming for web but just needs to learn the syntax of
ASP.Net (or whatever language) tries to learn.

The tutorial you sited shows <script language="vb" runat="server"> which
is one of the missing links for me... MS's tech docs showed all these
pieces of code, but no starting point on where to use them with asp.net.
This helps tie it all together.

And finally, to write asp.net apps or even to bundle C# or VB into
ASP.Net apps (like using the <script> tag above), do I need Visual
Studio.Net? We've already spent a pretty penny on SPS and on SPS books
assuming with the cost we had some native, outta the box method to query
databases, but we don't have another $600 to spend on VS.Net.

Thanks again for your help.. finally I see a pinpoint of light at the
end of the tunnel :)

Sam Alex
 
S

Sam ALex

Hi Juan,

This link along with the link Peter posted both help you tremendously!
My next step is getting some test pages written, then the fun part --
getting these to work with Sharepoint Portal as DWP files :)

Thanks again!

Sam Alex
 
M

Mythran

See comments in-line:


Sam ALex said:
Basically in a nutshell what I've written over the last 6+ years in
ColdFusion is a content management and document management system for
our Intranet, and though it works rather well, SPS has some features we
like... like being integrated into MS Office, Exchange, and Active
Directory. The only problem is we have so many custom 'dashboards' and
applications I've created in ColdFusion that it'll take time to
transpose these to ASP.Net (or whatever language is needed on SPS).

Just so ya know, ASP.Net is not a language. ASP.Net is a framework. The
code-behind, being C#, J#, C++, VB.Net are languages. Just letting ya know
so you can understand it all better...
You're right in that CF and ASP.Net are on two ends of the spectrum, and
with me knowing PHP as well I can see how having more options is
helpful... but MS doesn't help much when someone like me who has
experience programming for web but just needs to learn the syntax of
ASP.Net (or whatever language) tries to learn.

I see CF for those quick and dirty jobs, but for larger applications that
require n-tiers, more complex business logic, and a more flexible system, I
see ASP.Net being the hero (ok, overkill by using that term). But, get what
I mean?
The tutorial you sited shows <script language="vb" runat="server"> which
is one of the missing links for me... MS's tech docs showed all these
pieces of code, but no starting point on where to use them with asp.net.
This helps tie it all together.
You should really learn more about ASP.Net before jumping in, but as you
have stated, I don't think you have the time. Anywho, there are two ways to
write ASP.Net. 1.) Using code-behind pages (which are compiled into class
assemblies), and 2.) Writing in-line server-side code, which is what you
posted above.

To use server-side code:

<script language="vb" runat="server">
VB.Net code here
</script>

To use the better (IMO) way, using code-behind pre-pre-compiled assemblies:
top of ASPX page, place the following:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="codebehindpath.vb" Inherits="Namespace.ClassName" %>

example:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="index.aspx.vb"
Inherits="MCIS.Applications.Northwind.WebUI.index" %>

then you would place your ServerSide code into a text file named
"codebehindpath.vb" (named whatever, in my above example, it's
index.aspx.vb). This file will get compiled either by the .Net IDE or
command-line by you. Remember that since this is a server-side ASP.Net
code-behind file said:
And finally, to write asp.net apps or even to bundle C# or VB into
ASP.Net apps (like using the <script> tag above), do I need Visual
Studio.Net? We've already spent a pretty penny on SPS and on SPS books
assuming with the cost we had some native, outta the box method to query
databases, but we don't have another $600 to spend on VS.Net.
You do NOT need VS.Net to install or write .Net applications. All you need
VS.Net is to ease the burden of writing code and compiling. It is more of a
project manager and development studio than anything else. It doesn't even
contain the compiler. The compiler for .Net is free and is automatically
installed when you install the .Net framework. Most help on the Internet,
though, assumes you use the VS.Net ide (but in most cases, it doesn't
matter). The code examples come with a project file which is used in VS,
but you can compile them w/o VS.
Thanks again for your help.. finally I see a pinpoint of light at the
end of the tunnel :)

Sam Alex


I hope this has helped clear things up for ya a little :) In the end, I see
ASP.Net as a good solution for most problems, although there are better ways
to do things, ASP.Net is one way that will almost always work .. given
enough time and money, anything is possible [don't know who to quote].

Mythran
 
T

tom pester

And finally, to write asp.net apps or even to bundle C# or VB into
ASP.Net apps (like using the <script> tag above), do I need Visual
Studio.Net? We've already spent a pretty penny on SPS and on SPS
books assuming with the cost we had some native, outta the box method
to query databases, but we don't have another $600 to spend on VS.Net.

I got some good advice for you :
http://lab.msdn.microsoft.com/express/vwd/

"Visual Web Developer Express" is a great development tool that will assist
you greatly.
Its free for now and when its officialy released it will cost about 50$

Check out
http://lab.msdn.microsoft.com/vs2005/productinfo/productline/default.aspx
For all its capabilities.

(You can also check out the web matrix project at http://www.asp.net/webmatrix/default.aspx?tabIndex=4&tabId=46
but I recomend VWD which I consider its succesor)

By doing this you are also using the next version of asp.net (version 2)
wich is very stable and will come out November.
It will eleminate some of the show stoppers that you will encounter in version
1 (no need to mention them cause you will avoid them)

Summary : you don't need VS.NET at all to make good ASP apps

I saw an answer to this post that recommends putting all the code in a seperate
file. Alhough this is good coding practice I wouldn't start with this approuch.
(look up " asp.net code behind page" if you are intrested later)

Now the important part. Your goal is to write for PSP wich I am not familiar
with unfortunatly. What are DWP files aneway?
I'm sure we can help you here all the same.


I always wanted to learn PHP ( and CF also). Maybe you can set me on my way
with PHP :)

Can you recommend some
- sites
- books
- tools

Cheers,
Tom Pester
 

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

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top