Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Thursday, March 29, 2012

newbie: how to print stuff at the shell using C# while at programming in asp.net

Hi, I made myself a componment, so it can talk to the database.
I want to able to see the certain value within the code itself. And I'm unable to use asp:label control.
Is there's any way I can print stuff on the shell so I can keep track of where I'm at with my varable?
I tried Console.Write(temp); but it didn't seem to work :(
TIA
Use one of the System.Diagnostics.Debug.Writexxx() methods. These will appear in the Output Window in Visual Studio as you run the site under the debugger.
Alternatively, use the HttpContext.Current.Trace.Write() method, and this will put output into the ASP.NET Trace, which you can either see on the page or via the trace.axd handler.

Thank you very much DMW, System.Diagnostics.Debug.Writexxx() is useful

case close

Newbie: Image button aspect ratio

I have some image buttons which I am dynamically adding from a database. No
problems so far...
However, when it loads the image using IMAGEURL=, it doesn't keep the
original aspect ratio.
Is there a way to keep this without resizing the control?
Many thanks,
David Whitchurch-BennettThe aspect ratio is not affected at all by the ImageURL property. Most
likely you have the height or width of the control set to a value. If you
remove those values from the control, the image will come in at its normal
size, if you want it smaller (but wish to preserve the aspect ratio), then
just set a width or a height for the control but not both.
"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
>I have some image buttons which I am dynamically adding from a database. No
> problems so far...
> However, when it loads the image using IMAGEURL=, it doesn't keep the
> original aspect ratio.
> Is there a way to keep this without resizing the control?
> Many thanks,
> David Whitchurch-Bennett
>
Thanks for that information. What I have in my app is an image button set to
250 x 250, with a thick border which is all part of the visual theme. That i
s
why I have set the size first. What I want to do is load an image dynamicall
y
in the center of the image button, but keep the image button border the same
size, so the visual theme is preserved.
Is this possible, or will the only way be to place the image button into
another container with a border.
"Scott M." wrote:

> The aspect ratio is not affected at all by the ImageURL property. Most
> likely you have the height or width of the control set to a value. If you
> remove those values from the control, the image will come in at its normal
> size, if you want it smaller (but wish to preserve the aspect ratio), then
> just set a width or a height for the control but not both.
> "David Whitchurch-Bennett"
> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
> news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
>
>
I think this is more of an issue of having graphics that will fit into a
250x250 space that VS.NET sizing the images for you. Your best bet is to
use a good graphics tool to create images that will fit into that space,
rather than attempt to have VS.NET fit them for you.
"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:B4825793-D8BD-476C-96B8-9E63062C1B6F@.microsoft.com...
> Thanks for that information. What I have in my app is an image button set
> to
> 250 x 250, with a thick border which is all part of the visual theme. That
> is
> why I have set the size first. What I want to do is load an image
> dynamically
> in the center of the image button, but keep the image button border the
> same
> size, so the visual theme is preserved.
> Is this possible, or will the only way be to place the image button into
> another container with a border.
> "Scott M." wrote:
>
I already have this. I am using a class that I have written to scale down th
e
image first for two reasons.
1. To help the page load faster.
2. To prevent people downloading the full size images (photographic website)
.
Rather than resizing all of my photos, my class takes care of this by
scaling down the image. I pass the maximum width and height, and the image i
s
scaled down to fit and it maintains the aspect ratio.
When I put the scaled down image into the button, it stetches it out to fit
in both dimensions.
I guess I just asumed there would be a way to display the image without
stretching it out. I can pad the extra pixels in the function to return a
square image if that is a better way.
Thanks for your help. ASP.NET is quite different to what I am used to, but I
am getting there!
"Scott M." wrote:

> I think this is more of an issue of having graphics that will fit into a
> 250x250 space that VS.NET sizing the images for you. Your best bet is to
> use a good graphics tool to create images that will fit into that space,
> rather than attempt to have VS.NET fit them for you.
> "David Whitchurch-Bennett"
> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
> news:B4825793-D8BD-476C-96B8-9E63062C1B6F@.microsoft.com...
>
>
How about putting the image into an image control (not a button image
control) and overlaying the image control on top of your button control?
"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:C9567572-5BBC-4DE9-83C9-44BE4F3465F4@.microsoft.com...
>I already have this. I am using a class that I have written to scale down
>the
> image first for two reasons.
> 1. To help the page load faster.
> 2. To prevent people downloading the full size images (photographic
> website).
> Rather than resizing all of my photos, my class takes care of this by
> scaling down the image. I pass the maximum width and height, and the image
> is
> scaled down to fit and it maintains the aspect ratio.
> When I put the scaled down image into the button, it stetches it out to
> fit
> in both dimensions.
> I guess I just asumed there would be a way to display the image without
> stretching it out. I can pad the extra pixels in the function to return a
> square image if that is a better way.
> Thanks for your help. ASP.NET is quite different to what I am used to, but
> I
> am getting there!
> "Scott M." wrote:
>
I ran into the same problem... I found an easy to solution to prevent scalin
g is to use a hyperlink control and set its imageurl property to the image i
n question.

Newbie: Image button aspect ratio

I have some image buttons which I am dynamically adding from a database. No
problems so far...

However, when it loads the image using IMAGEURL=, it doesn't keep the
original aspect ratio.

Is there a way to keep this without resizing the control?

Many thanks,

David Whitchurch-BennettThe aspect ratio is not affected at all by the ImageURL property. Most
likely you have the height or width of the control set to a value. If you
remove those values from the control, the image will come in at its normal
size, if you want it smaller (but wish to preserve the aspect ratio), then
just set a width or a height for the control but not both.

"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
>I have some image buttons which I am dynamically adding from a database. No
> problems so far...
> However, when it loads the image using IMAGEURL=, it doesn't keep the
> original aspect ratio.
> Is there a way to keep this without resizing the control?
> Many thanks,
> David Whitchurch-Bennett
Thanks for that information. What I have in my app is an image button set to
250 x 250, with a thick border which is all part of the visual theme. That is
why I have set the size first. What I want to do is load an image dynamically
in the center of the image button, but keep the image button border the same
size, so the visual theme is preserved.

Is this possible, or will the only way be to place the image button into
another container with a border.

"Scott M." wrote:

> The aspect ratio is not affected at all by the ImageURL property. Most
> likely you have the height or width of the control set to a value. If you
> remove those values from the control, the image will come in at its normal
> size, if you want it smaller (but wish to preserve the aspect ratio), then
> just set a width or a height for the control but not both.
> "David Whitchurch-Bennett"
> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
> news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
> >I have some image buttons which I am dynamically adding from a database. No
> > problems so far...
> > However, when it loads the image using IMAGEURL=, it doesn't keep the
> > original aspect ratio.
> > Is there a way to keep this without resizing the control?
> > Many thanks,
> > David Whitchurch-Bennett
>
I think this is more of an issue of having graphics that will fit into a
250x250 space that VS.NET sizing the images for you. Your best bet is to
use a good graphics tool to create images that will fit into that space,
rather than attempt to have VS.NET fit them for you.

"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:B4825793-D8BD-476C-96B8-9E63062C1B6F@.microsoft.com...
> Thanks for that information. What I have in my app is an image button set
> to
> 250 x 250, with a thick border which is all part of the visual theme. That
> is
> why I have set the size first. What I want to do is load an image
> dynamically
> in the center of the image button, but keep the image button border the
> same
> size, so the visual theme is preserved.
> Is this possible, or will the only way be to place the image button into
> another container with a border.
> "Scott M." wrote:
>> The aspect ratio is not affected at all by the ImageURL property. Most
>> likely you have the height or width of the control set to a value. If
>> you
>> remove those values from the control, the image will come in at its
>> normal
>> size, if you want it smaller (but wish to preserve the aspect ratio),
>> then
>> just set a width or a height for the control but not both.
>>
>> "David Whitchurch-Bennett"
>> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
>> news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
>> >I have some image buttons which I am dynamically adding from a database.
>> >No
>> > problems so far...
>>> > However, when it loads the image using IMAGEURL=, it doesn't keep the
>> > original aspect ratio.
>>> > Is there a way to keep this without resizing the control?
>>> > Many thanks,
>>> > David Whitchurch-Bennett
>>>
>>
>
I already have this. I am using a class that I have written to scale down the
image first for two reasons.

1. To help the page load faster.
2. To prevent people downloading the full size images (photographic website).

Rather than resizing all of my photos, my class takes care of this by
scaling down the image. I pass the maximum width and height, and the image is
scaled down to fit and it maintains the aspect ratio.

When I put the scaled down image into the button, it stetches it out to fit
in both dimensions.

I guess I just asumed there would be a way to display the image without
stretching it out. I can pad the extra pixels in the function to return a
square image if that is a better way.

Thanks for your help. ASP.NET is quite different to what I am used to, but I
am getting there!

"Scott M." wrote:

> I think this is more of an issue of having graphics that will fit into a
> 250x250 space that VS.NET sizing the images for you. Your best bet is to
> use a good graphics tool to create images that will fit into that space,
> rather than attempt to have VS.NET fit them for you.
> "David Whitchurch-Bennett"
> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
> news:B4825793-D8BD-476C-96B8-9E63062C1B6F@.microsoft.com...
> > Thanks for that information. What I have in my app is an image button set
> > to
> > 250 x 250, with a thick border which is all part of the visual theme. That
> > is
> > why I have set the size first. What I want to do is load an image
> > dynamically
> > in the center of the image button, but keep the image button border the
> > same
> > size, so the visual theme is preserved.
> > Is this possible, or will the only way be to place the image button into
> > another container with a border.
> > "Scott M." wrote:
> >> The aspect ratio is not affected at all by the ImageURL property. Most
> >> likely you have the height or width of the control set to a value. If
> >> you
> >> remove those values from the control, the image will come in at its
> >> normal
> >> size, if you want it smaller (but wish to preserve the aspect ratio),
> >> then
> >> just set a width or a height for the control but not both.
> >>
> >> "David Whitchurch-Bennett"
> >> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
> >> news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
> >> >I have some image buttons which I am dynamically adding from a database.
> >> >No
> >> > problems so far...
> >> >> > However, when it loads the image using IMAGEURL=, it doesn't keep the
> >> > original aspect ratio.
> >> >> > Is there a way to keep this without resizing the control?
> >> >> > Many thanks,
> >> >> > David Whitchurch-Bennett
> >> >>
> >>
> >>
>
How about putting the image into an image control (not a button image
control) and overlaying the image control on top of your button control?

"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:C9567572-5BBC-4DE9-83C9-44BE4F3465F4@.microsoft.com...
>I already have this. I am using a class that I have written to scale down
>the
> image first for two reasons.
> 1. To help the page load faster.
> 2. To prevent people downloading the full size images (photographic
> website).
> Rather than resizing all of my photos, my class takes care of this by
> scaling down the image. I pass the maximum width and height, and the image
> is
> scaled down to fit and it maintains the aspect ratio.
> When I put the scaled down image into the button, it stetches it out to
> fit
> in both dimensions.
> I guess I just asumed there would be a way to display the image without
> stretching it out. I can pad the extra pixels in the function to return a
> square image if that is a better way.
> Thanks for your help. ASP.NET is quite different to what I am used to, but
> I
> am getting there!
> "Scott M." wrote:
>> I think this is more of an issue of having graphics that will fit into a
>> 250x250 space that VS.NET sizing the images for you. Your best bet is to
>> use a good graphics tool to create images that will fit into that space,
>> rather than attempt to have VS.NET fit them for you.
>>
>> "David Whitchurch-Bennett"
>> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
>> news:B4825793-D8BD-476C-96B8-9E63062C1B6F@.microsoft.com...
>> > Thanks for that information. What I have in my app is an image button
>> > set
>> > to
>> > 250 x 250, with a thick border which is all part of the visual theme.
>> > That
>> > is
>> > why I have set the size first. What I want to do is load an image
>> > dynamically
>> > in the center of the image button, but keep the image button border the
>> > same
>> > size, so the visual theme is preserved.
>>> > Is this possible, or will the only way be to place the image button
>> > into
>> > another container with a border.
>>> > "Scott M." wrote:
>>> >> The aspect ratio is not affected at all by the ImageURL property.
>> >> Most
>> >> likely you have the height or width of the control set to a value. If
>> >> you
>> >> remove those values from the control, the image will come in at its
>> >> normal
>> >> size, if you want it smaller (but wish to preserve the aspect ratio),
>> >> then
>> >> just set a width or a height for the control but not both.
>> >>
>> >> "David Whitchurch-Bennett"
>> >> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
>> >> news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
>> >> >I have some image buttons which I am dynamically adding from a
>> >> >database.
>> >> >No
>> >> > problems so far...
>> >>> >> > However, when it loads the image using IMAGEURL=, it doesn't keep
>> >> > the
>> >> > original aspect ratio.
>> >>> >> > Is there a way to keep this without resizing the control?
>> >>> >> > Many thanks,
>> >>> >> > David Whitchurch-Bennett
>> >>> >>
>> >>
>> >>
>>
>>
>

Monday, March 26, 2012

Newbie: Propably simple answer Checkbox_checked?

Hi there

I what to test a stored procedures on a web page using the normal connection
string.
the controls: Server, username,Password, database allow to select the
appropriate Sql server database.
Now I would use checkbox = Trusted connection as option to logon to the
database.

I guess the question that I have is where am I going wrong in the code?
How can I step through the script before or up until the page is loaded?

Any hints are greatly appreciated, the same will be made available after
completion.

Regards

Norman

Here is the Code:-----------------
<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="True" %>
<%@dotnet.itags.org. import Namespace="System.Data" %>
<%@dotnet.itags.org. import Namespace="System.Data.SqlClient" %>
<%@dotnet.itags.org. import Namespace="System.Web.UI.WebControls" %>
<HTML>
<HEAD>
<script runat="server"
' code to check if the tickbox was ticked

Sub Check_Clicked(sender As Object, e As EventArgs)

If WinTrusted.checked then
'Dim conn As New SqlConnection( _
' "Data source=" & DatabaseServer.Text & _
' ";Trusted_Connection=true" & _
' ";Initial catalog=" & Database.Text)
'else
'Dim conn As New SqlConnection( _
' "Data source=" & DatabaseServer.Text & _
' ";Trusted_Connection=true" & _
' ";Initial catalog=" & Database.Text)
end if
End Sub
'
Sub LoginButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim ds As New DataSet
Dim conn As New SqlConnection( _
"Data source=" & DatabaseServer.Text & _
";Trusted_Connection=true" & _
";Initial catalog=" & Database.Text)

Dim cmd As New SqlCommand("sp_stored_procedures", conn) ' << when Sub
Check_Clicked and the code is run Asp courses an error at this line saying
that "conn" is not defined??
Dim adpt As New SqlDataAdapter(cmd)
Try
Status.Text = ""
adpt.Fill(ds, "SPs")
SPs.DataSource = ds.Tables("SPs")
SPs.DataTextField = "PROCEDURE_NAME"
SPs.DataBind()
Catch ex As SqlException
Status.Text = ex.Message
End Try
End Sub
Sub GetParametersButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim ds As New DataSet
'If Wintrusted.checked = True Then
' Dim conn As New SqlConnection( _
' "Data source=" & DatabaseServer.Text & _
' ";Trusted_Connection=true" & _
' ";Initial catalog=" & Database.Text)
'Else
Dim conn As New SqlConnection( _
"Data source=" & DatabaseServer.Text & _
";User id=" & Userid.text & _
";Password=" & Password.Text & _
";Initial catalog=" & Database.Text)
'End If
Dim cmd As New SqlCommand("sp_sproc_columns", conn) '' << when Sub
Check_Clicked and the code is run Asp courses an error at this line saying
that "conn" is not defined??
Dim adpt As New SqlDataAdapter(cmd)
Try
Status.Text = ""
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@dotnet.itags.org.procedure_name", SqlDbType.NVarchar, 390).Value = _
SPs.SelectedItem.Value
adpt.Fill(ds, "Parameters")
ParametersDataGrid.DataSource = ds.Tables("Parameters")
ParametersDataGrid.DataBind()
ResultsDataGrid.Visible = False
Catch ex As SqlException
Status.Text = ex.Message
End Try
End Sub

Sub AddParameters(ByVal cmd As SqlCommand)
'works ok
End Sub

Sub UpdateParameters(ByVal cmd As SqlCommand)
'Works Ok
End Sub

Sub ExecuteQueryButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim ds As New DataSet
'If WinTrusted.checked then
'Dim conn As New SqlConnection( _
' "Data source=" & DatabaseServer.Text & _
' ";Trusted_Connection=true" & _
' ";Initial catalog=" & Database.Text)
'else
Dim conn As New SqlConnection( _
"Data source=" & DatabaseServer.Text & _
";Trusted_Connection=true" & _
";Initial catalog=" & Database.Text)
'end if
Dim cmd As New SqlCommand(SPs.SelectedItem.Value, conn) ' ' << when Sub
Check_Clicked and the code is run Asp courses an error at this line saying
that "conn" is not defined??
Dim adpt As New SqlDataAdapter(cmd)
Try
Status.Text = ""
cmd.CommandType = CommandType.StoredProcedure
AddParameters(cmd)
adpt.Fill(ds, "Results")
UpdateParameters(cmd)
ResultsDataGrid.DataSource = ds.Tables("Results")
ResultsDataGrid.DataBind()
ResultsDataGrid.Visible = True
Catch ex As SqlException
Status.Text = ex.Message
End Try
End Sub
</script>
</HEAD>
----------End of
Code--------------You problem i think is happening because you are defining the connection in
a if statement
that would make it a local variable of
if(conditional statement)
{
// you code and your variables.
// any variables declared here are local to this if statement..
}

try
SqlConnection conn;
if(WinTrusted.checked == true)
con = new SqlConnection("con paramas")
else
con = new SqlConnection("second set of param")
}
SqlDataAdapter myCommand = new SqlDataAdapter("sp_storedproc", myCon)
myCommand.SelectCommand.CommandType = CommandType.StoredProc

This should work,

Hermit Dave

"Norman Fritag" <mtp.net@.ozemail.com.au> wrote in message
news:cY6Cb.10$Tq.1083@.nnrp1.ozemail.com.au...
> Hi there
> I what to test a stored procedures on a web page using the normal
connection
> string.
> the controls: Server, username,Password, database allow to select the
> appropriate Sql server database.
> Now I would use checkbox = Trusted connection as option to logon to the
> database.
> I guess the question that I have is where am I going wrong in the code?
> How can I step through the script before or up until the page is loaded?
> Any hints are greatly appreciated, the same will be made available after
> completion.
> Regards
> Norman
>
> Here is the Code:-----------------
> <%@. Page Language="VB" AutoEventWireup="True" %>
> <%@. import Namespace="System.Data" %>
> <%@. import Namespace="System.Data.SqlClient" %>
> <%@. import Namespace="System.Web.UI.WebControls" %>
> <HTML>
> <HEAD>
> <script runat="server">
> ' code to check if the tickbox was ticked
> Sub Check_Clicked(sender As Object, e As EventArgs)
> If WinTrusted.checked then
> 'Dim conn As New SqlConnection( _
> ' "Data source=" & DatabaseServer.Text & _
> ' ";Trusted_Connection=true" & _
> ' ";Initial catalog=" & Database.Text)
> 'else
> 'Dim conn As New SqlConnection( _
> ' "Data source=" & DatabaseServer.Text & _
> ' ";Trusted_Connection=true" & _
> ' ";Initial catalog=" & Database.Text)
> end if
> End Sub
> '
> Sub LoginButton_Click(ByVal sender As Object, ByVal e As EventArgs)
> Dim ds As New DataSet
> Dim conn As New SqlConnection( _
> "Data source=" & DatabaseServer.Text & _
> ";Trusted_Connection=true" & _
> ";Initial catalog=" & Database.Text)
> Dim cmd As New SqlCommand("sp_stored_procedures", conn) ' << when Sub
> Check_Clicked and the code is run Asp courses an error at this line saying
> that "conn" is not defined??
> Dim adpt As New SqlDataAdapter(cmd)
> Try
> Status.Text = ""
> adpt.Fill(ds, "SPs")
> SPs.DataSource = ds.Tables("SPs")
> SPs.DataTextField = "PROCEDURE_NAME"
> SPs.DataBind()
> Catch ex As SqlException
> Status.Text = ex.Message
> End Try
> End Sub
> Sub GetParametersButton_Click(ByVal sender As Object, ByVal e As
EventArgs)
> Dim ds As New DataSet
> 'If Wintrusted.checked = True Then
> ' Dim conn As New SqlConnection( _
> ' "Data source=" & DatabaseServer.Text & _
> ' ";Trusted_Connection=true" & _
> ' ";Initial catalog=" & Database.Text)
> 'Else
> Dim conn As New SqlConnection( _
> "Data source=" & DatabaseServer.Text & _
> ";User id=" & Userid.text & _
> ";Password=" & Password.Text & _
> ";Initial catalog=" & Database.Text)
> 'End If
> Dim cmd As New SqlCommand("sp_sproc_columns", conn) '' << when Sub
> Check_Clicked and the code is run Asp courses an error at this line saying
> that "conn" is not defined??
> Dim adpt As New SqlDataAdapter(cmd)
> Try
> Status.Text = ""
> cmd.CommandType = CommandType.StoredProcedure
> cmd.Parameters.Add("@.procedure_name", SqlDbType.NVarchar, 390).Value = _
> SPs.SelectedItem.Value
> adpt.Fill(ds, "Parameters")
> ParametersDataGrid.DataSource = ds.Tables("Parameters")
> ParametersDataGrid.DataBind()
> ResultsDataGrid.Visible = False
> Catch ex As SqlException
> Status.Text = ex.Message
> End Try
> End Sub
> Sub AddParameters(ByVal cmd As SqlCommand)
> 'works ok
> End Sub
> Sub UpdateParameters(ByVal cmd As SqlCommand)
> 'Works Ok
> End Sub
> Sub ExecuteQueryButton_Click(ByVal sender As Object, ByVal e As EventArgs)
> Dim ds As New DataSet
> 'If WinTrusted.checked then
> 'Dim conn As New SqlConnection( _
> ' "Data source=" & DatabaseServer.Text & _
> ' ";Trusted_Connection=true" & _
> ' ";Initial catalog=" & Database.Text)
> 'else
> Dim conn As New SqlConnection( _
> "Data source=" & DatabaseServer.Text & _
> ";Trusted_Connection=true" & _
> ";Initial catalog=" & Database.Text)
> 'end if
> Dim cmd As New SqlCommand(SPs.SelectedItem.Value, conn) ' ' << when Sub
> Check_Clicked and the code is run Asp courses an error at this line saying
> that "conn" is not defined??
> Dim adpt As New SqlDataAdapter(cmd)
> Try
> Status.Text = ""
> cmd.CommandType = CommandType.StoredProcedure
> AddParameters(cmd)
> adpt.Fill(ds, "Results")
> UpdateParameters(cmd)
> ResultsDataGrid.DataSource = ds.Tables("Results")
> ResultsDataGrid.DataBind()
> ResultsDataGrid.Visible = True
> Catch ex As SqlException
> Status.Text = ex.Message
> End Try
> End Sub
> </script>
> </HEAD>
> ----------End of
> Code--------------
Sorry bout the typos... too knackered... and too hungry and i would do with
some food and some sleep...

Your problem i think is happening because you are defining the connection in
a if statement
that would make it a local variable of
if(conditional statement)
{
// you code and your variables.
// any variables declared here are local to this if statement..
}

try
SqlConnection conn;
if(WinTrusted.checked == true)
conn = new SqlConnection("con paramas")
else
conn = new SqlConnection("second set of param")
}
SqlDataAdapter myCommand = new SqlDataAdapter("sp_storedproc", conn)
myCommand.SelectCommand.CommandType = CommandType.StoredProc

This should work,

Hermit Dave

"Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
news:evdi6$DwDHA.2372@.TK2MSFTNGP09.phx.gbl...
> You problem i think is happening because you are defining the connection
in
> a if statement
> that would make it a local variable of
> if(conditional statement)
> {
> // you code and your variables.
> // any variables declared here are local to this if statement..
> }
> try
> SqlConnection conn;
> if(WinTrusted.checked == true)
> con = new SqlConnection("con paramas")
> else
> con = new SqlConnection("second set of param")
> }
> SqlDataAdapter myCommand = new SqlDataAdapter("sp_storedproc", myCon)
> myCommand.SelectCommand.CommandType = CommandType.StoredProc
> This should work,
> Hermit Dave
> "Norman Fritag" <mtp.net@.ozemail.com.au> wrote in message
> news:cY6Cb.10$Tq.1083@.nnrp1.ozemail.com.au...
> > Hi there
> > I what to test a stored procedures on a web page using the normal
> connection
> > string.
> > the controls: Server, username,Password, database allow to select the
> > appropriate Sql server database.
> > Now I would use checkbox = Trusted connection as option to logon to the
> > database.
> > I guess the question that I have is where am I going wrong in the code?
> > How can I step through the script before or up until the page is loaded?
> > Any hints are greatly appreciated, the same will be made available after
> > completion.
> > Regards
> > Norman
> > Here is the Code:-----------------
> > <%@. Page Language="VB" AutoEventWireup="True" %>
> > <%@. import Namespace="System.Data" %>
> > <%@. import Namespace="System.Data.SqlClient" %>
> > <%@. import Namespace="System.Web.UI.WebControls" %>
> > <HTML>
> > <HEAD>
> > <script runat="server">
> > ' code to check if the tickbox was ticked
> > Sub Check_Clicked(sender As Object, e As EventArgs)
> > If WinTrusted.checked then
> > 'Dim conn As New SqlConnection( _
> > ' "Data source=" & DatabaseServer.Text & _
> > ' ";Trusted_Connection=true" & _
> > ' ";Initial catalog=" & Database.Text)
> > 'else
> > 'Dim conn As New SqlConnection( _
> > ' "Data source=" & DatabaseServer.Text & _
> > ' ";Trusted_Connection=true" & _
> > ' ";Initial catalog=" & Database.Text)
> > end if
> > End Sub
> > '
> > Sub LoginButton_Click(ByVal sender As Object, ByVal e As EventArgs)
> > Dim ds As New DataSet
> > Dim conn As New SqlConnection( _
> > "Data source=" & DatabaseServer.Text & _
> > ";Trusted_Connection=true" & _
> > ";Initial catalog=" & Database.Text)
> > Dim cmd As New SqlCommand("sp_stored_procedures", conn) ' << when Sub
> > Check_Clicked and the code is run Asp courses an error at this line
saying
> > that "conn" is not defined??
> > Dim adpt As New SqlDataAdapter(cmd)
> > Try
> > Status.Text = ""
> > adpt.Fill(ds, "SPs")
> > SPs.DataSource = ds.Tables("SPs")
> > SPs.DataTextField = "PROCEDURE_NAME"
> > SPs.DataBind()
> > Catch ex As SqlException
> > Status.Text = ex.Message
> > End Try
> > End Sub
> > Sub GetParametersButton_Click(ByVal sender As Object, ByVal e As
> EventArgs)
> > Dim ds As New DataSet
> > 'If Wintrusted.checked = True Then
> > ' Dim conn As New SqlConnection( _
> > ' "Data source=" & DatabaseServer.Text & _
> > ' ";Trusted_Connection=true" & _
> > ' ";Initial catalog=" & Database.Text)
> > 'Else
> > Dim conn As New SqlConnection( _
> > "Data source=" & DatabaseServer.Text & _
> > ";User id=" & Userid.text & _
> > ";Password=" & Password.Text & _
> > ";Initial catalog=" & Database.Text)
> > 'End If
> > Dim cmd As New SqlCommand("sp_sproc_columns", conn) '' << when Sub
> > Check_Clicked and the code is run Asp courses an error at this line
saying
> > that "conn" is not defined??
> > Dim adpt As New SqlDataAdapter(cmd)
> > Try
> > Status.Text = ""
> > cmd.CommandType = CommandType.StoredProcedure
> > cmd.Parameters.Add("@.procedure_name", SqlDbType.NVarchar, 390).Value = _
> > SPs.SelectedItem.Value
> > adpt.Fill(ds, "Parameters")
> > ParametersDataGrid.DataSource = ds.Tables("Parameters")
> > ParametersDataGrid.DataBind()
> > ResultsDataGrid.Visible = False
> > Catch ex As SqlException
> > Status.Text = ex.Message
> > End Try
> > End Sub
> > Sub AddParameters(ByVal cmd As SqlCommand)
> > 'works ok
> > End Sub
> > Sub UpdateParameters(ByVal cmd As SqlCommand)
> > 'Works Ok
> > End Sub
> > Sub ExecuteQueryButton_Click(ByVal sender As Object, ByVal e As
EventArgs)
> > Dim ds As New DataSet
> > 'If WinTrusted.checked then
> > 'Dim conn As New SqlConnection( _
> > ' "Data source=" & DatabaseServer.Text & _
> > ' ";Trusted_Connection=true" & _
> > ' ";Initial catalog=" & Database.Text)
> > 'else
> > Dim conn As New SqlConnection( _
> > "Data source=" & DatabaseServer.Text & _
> > ";Trusted_Connection=true" & _
> > ";Initial catalog=" & Database.Text)
> > 'end if
> > Dim cmd As New SqlCommand(SPs.SelectedItem.Value, conn) ' ' << when Sub
> > Check_Clicked and the code is run Asp courses an error at this line
saying
> > that "conn" is not defined??
> > Dim adpt As New SqlDataAdapter(cmd)
> > Try
> > Status.Text = ""
> > cmd.CommandType = CommandType.StoredProcedure
> > AddParameters(cmd)
> > adpt.Fill(ds, "Results")
> > UpdateParameters(cmd)
> > ResultsDataGrid.DataSource = ds.Tables("Results")
> > ResultsDataGrid.DataBind()
> > ResultsDataGrid.Visible = True
> > Catch ex As SqlException
> > Status.Text = ex.Message
> > End Try
> > End Sub
> > </script>
> > </HEAD>
> > ----------End of
> > Code--------------
Thanks Hermit Dave
I picked up the thought an it works Ok.
Regards

Norman

"Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
news:evdi6$DwDHA.2372@.TK2MSFTNGP09.phx.gbl...
> You problem i think is happening because you are defining the connection
in
> a if statement
> that would make it a local variable of
> if(conditional statement)
> {
> // you code and your variables.
> // any variables declared here are local to this if statement..
> }
> try
> SqlConnection conn;
> if(WinTrusted.checked == true)
> con = new SqlConnection("con paramas")
> else
> con = new SqlConnection("second set of param")
> }
> SqlDataAdapter myCommand = new SqlDataAdapter("sp_storedproc", myCon)
> myCommand.SelectCommand.CommandType = CommandType.StoredProc
> This should work,
> Hermit Dave
> "Norman Fritag" <mtp.net@.ozemail.com.au> wrote in message
> news:cY6Cb.10$Tq.1083@.nnrp1.ozemail.com.au...
> > Hi there
> > I what to test a stored procedures on a web page using the normal
> connection
> > string.
> > the controls: Server, username,Password, database allow to select the
> > appropriate Sql server database.
> > Now I would use checkbox = Trusted connection as option to logon to the
> > database.
> > I guess the question that I have is where am I going wrong in the code?
> > How can I step through the script before or up until the page is loaded?
> > Any hints are greatly appreciated, the same will be made available after
> > completion.
> > Regards
> > Norman
> > Here is the Code:-----------------
> > <%@. Page Language="VB" AutoEventWireup="True" %>
> > <%@. import Namespace="System.Data" %>
> > <%@. import Namespace="System.Data.SqlClient" %>
> > <%@. import Namespace="System.Web.UI.WebControls" %>
> > <HTML>
> > <HEAD>
> > <script runat="server">
> > ' code to check if the tickbox was ticked
> > Sub Check_Clicked(sender As Object, e As EventArgs)
> > If WinTrusted.checked then
> > 'Dim conn As New SqlConnection( _
> > ' "Data source=" & DatabaseServer.Text & _
> > ' ";Trusted_Connection=true" & _
> > ' ";Initial catalog=" & Database.Text)
> > 'else
> > 'Dim conn As New SqlConnection( _
> > ' "Data source=" & DatabaseServer.Text & _
> > ' ";Trusted_Connection=true" & _
> > ' ";Initial catalog=" & Database.Text)
> > end if
> > End Sub
> > '
> > Sub LoginButton_Click(ByVal sender As Object, ByVal e As EventArgs)
> > Dim ds As New DataSet
> > Dim conn As New SqlConnection( _
> > "Data source=" & DatabaseServer.Text & _
> > ";Trusted_Connection=true" & _
> > ";Initial catalog=" & Database.Text)
> > Dim cmd As New SqlCommand("sp_stored_procedures", conn) ' << when Sub
> > Check_Clicked and the code is run Asp courses an error at this line
saying
> > that "conn" is not defined??
> > Dim adpt As New SqlDataAdapter(cmd)
> > Try
> > Status.Text = ""
> > adpt.Fill(ds, "SPs")
> > SPs.DataSource = ds.Tables("SPs")
> > SPs.DataTextField = "PROCEDURE_NAME"
> > SPs.DataBind()
> > Catch ex As SqlException
> > Status.Text = ex.Message
> > End Try
> > End Sub
> > Sub GetParametersButton_Click(ByVal sender As Object, ByVal e As
> EventArgs)
> > Dim ds As New DataSet
> > 'If Wintrusted.checked = True Then
> > ' Dim conn As New SqlConnection( _
> > ' "Data source=" & DatabaseServer.Text & _
> > ' ";Trusted_Connection=true" & _
> > ' ";Initial catalog=" & Database.Text)
> > 'Else
> > Dim conn As New SqlConnection( _
> > "Data source=" & DatabaseServer.Text & _
> > ";User id=" & Userid.text & _
> > ";Password=" & Password.Text & _
> > ";Initial catalog=" & Database.Text)
> > 'End If
> > Dim cmd As New SqlCommand("sp_sproc_columns", conn) '' << when Sub
> > Check_Clicked and the code is run Asp courses an error at this line
saying
> > that "conn" is not defined??
> > Dim adpt As New SqlDataAdapter(cmd)
> > Try
> > Status.Text = ""
> > cmd.CommandType = CommandType.StoredProcedure
> > cmd.Parameters.Add("@.procedure_name", SqlDbType.NVarchar, 390).Value = _
> > SPs.SelectedItem.Value
> > adpt.Fill(ds, "Parameters")
> > ParametersDataGrid.DataSource = ds.Tables("Parameters")
> > ParametersDataGrid.DataBind()
> > ResultsDataGrid.Visible = False
> > Catch ex As SqlException
> > Status.Text = ex.Message
> > End Try
> > End Sub
> > Sub AddParameters(ByVal cmd As SqlCommand)
> > 'works ok
> > End Sub
> > Sub UpdateParameters(ByVal cmd As SqlCommand)
> > 'Works Ok
> > End Sub
> > Sub ExecuteQueryButton_Click(ByVal sender As Object, ByVal e As
EventArgs)
> > Dim ds As New DataSet
> > 'If WinTrusted.checked then
> > 'Dim conn As New SqlConnection( _
> > ' "Data source=" & DatabaseServer.Text & _
> > ' ";Trusted_Connection=true" & _
> > ' ";Initial catalog=" & Database.Text)
> > 'else
> > Dim conn As New SqlConnection( _
> > "Data source=" & DatabaseServer.Text & _
> > ";Trusted_Connection=true" & _
> > ";Initial catalog=" & Database.Text)
> > 'end if
> > Dim cmd As New SqlCommand(SPs.SelectedItem.Value, conn) ' ' << when Sub
> > Check_Clicked and the code is run Asp courses an error at this line
saying
> > that "conn" is not defined??
> > Dim adpt As New SqlDataAdapter(cmd)
> > Try
> > Status.Text = ""
> > cmd.CommandType = CommandType.StoredProcedure
> > AddParameters(cmd)
> > adpt.Fill(ds, "Results")
> > UpdateParameters(cmd)
> > ResultsDataGrid.DataSource = ds.Tables("Results")
> > ResultsDataGrid.DataBind()
> > ResultsDataGrid.Visible = True
> > Catch ex As SqlException
> > Status.Text = ex.Message
> > End Try
> > End Sub
> > </script>
> > </HEAD>
> > ----------End of
> > Code--------------

Thursday, March 22, 2012

Newbie-ish Question about Building Reports from a Datamart

Hello,

I am not brand new to .NET, but I'm still a beginner.

We have an Oracle database that nicely compacts (cubes) the data we need
(think mini-data mart). Unfortunately, this data is currently placed in
about 20 different huge Excel sheets for distribution. Ick!

What I would like to do is have a page that the user sees the different
sections (such as Headcount or Turnover) and can then drill-down into those
sections (such as by the Area - Northeast, Southeast and by the Level such
as Manager or Associate). Then save those settings and next month run that
same report with the saved settings. Obviously the data would be refreshed.

For example:

TURNOVER

Northeast

Managers

Associates

HEADCOUNT

Southwest

Managers

Southeast

Senior Associates

Associates

All the data is already compiled it is just a matter of allowing the user to
get to the breakdown of the data they want to see.

Is this possible? Does using Crystal make any sense? Are they any books,
websites, examples that you'd could recommend to me?

Thank you for the advice and help.Gummy,

If you are using Visual Studio 2005 I've been hearing really good things
about the new report controls so I'd take a look at those first. I've had
decent success using Crystal Reports myself, but they are difficult to work
with and I've seen lots of posts complaining about them. But still, as I
said, they are a viable route to go that I've used successfully.

Regards,

--
S. Justin Gengo
Web Developer / Programmer

Free code library:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche

"Gummy" <gumbatman@.hotmail.com> wrote in message
news:122qp8jljsthd0d@.corp.supernews.com...
> Hello,
>
> I am not brand new to .NET, but I'm still a beginner.
>
> We have an Oracle database that nicely compacts (cubes) the data we need
> (think mini-data mart). Unfortunately, this data is currently placed in
> about 20 different huge Excel sheets for distribution. Ick!
>
> What I would like to do is have a page that the user sees the different
> sections (such as Headcount or Turnover) and can then drill-down into
> those
> sections (such as by the Area - Northeast, Southeast and by the Level such
> as Manager or Associate). Then save those settings and next month run that
> same report with the saved settings. Obviously the data would be
> refreshed.
>
> For example:
> TURNOVER
> Northeast
> Managers
> Associates
> HEADCOUNT
> Southwest
> Managers
> Southeast
> Senior Associates
> Associates
>
>
>
> All the data is already compiled it is just a matter of allowing the user
> to
> get to the breakdown of the data they want to see.
>
> Is this possible? Does using Crystal make any sense? Are they any books,
> websites, examples that you'd could recommend to me?
>
> Thank you for the advice and help.
S. Justin,

Thank you for the response. I am using VS 2003 and I was looking for some
examples or templates so I can get a picture of how this might look.

Can you recommend any sites, books, etc?

Thank you.

"S. Justin Gengo" <justin@.[remove to send mail]aboutfortunate.com> wrote in
message news:%23Ab7gjOVGHA.5900@.tk2msftngp13.phx.gbl...
> Gummy,
> If you are using Visual Studio 2005 I've been hearing really good things
> about the new report controls so I'd take a look at those first. I've had
> decent success using Crystal Reports myself, but they are difficult to
work
> with and I've seen lots of posts complaining about them. But still, as I
> said, they are a viable route to go that I've used successfully.
> Regards,
> --
> S. Justin Gengo
> Web Developer / Programmer
> Free code library:
> http://www.aboutfortunate.com
> "Out of chaos comes order."
> Nietzsche
>
> "Gummy" <gumbatman@.hotmail.com> wrote in message
> news:122qp8jljsthd0d@.corp.supernews.com...
> > Hello,
> > I am not brand new to .NET, but I'm still a beginner.
> > We have an Oracle database that nicely compacts (cubes) the data we need
> > (think mini-data mart). Unfortunately, this data is currently placed in
> > about 20 different huge Excel sheets for distribution. Ick!
> > What I would like to do is have a page that the user sees the different
> > sections (such as Headcount or Turnover) and can then drill-down into
> > those
> > sections (such as by the Area - Northeast, Southeast and by the Level
such
> > as Manager or Associate). Then save those settings and next month run
that
> > same report with the saved settings. Obviously the data would be
> > refreshed.
> > For example:
> > TURNOVER
> > Northeast
> > Managers
> > Associates
> > HEADCOUNT
> > Southwest
> > Managers
> > Southeast
> > Senior Associates
> > Associates
> > All the data is already compiled it is just a matter of allowing the
user
> > to
> > get to the breakdown of the data they want to see.
> > Is this possible? Does using Crystal make any sense? Are they any books,
> > websites, examples that you'd could recommend to me?
> > Thank you for the advice and help.
Gummy,

Sure here are a couple of links to get you started:

http://aspalliance.com/sql-reporting/

http://aspalliance.com/crystal/default.aspx

Sincerely,

--
S. Justin Gengo
Web Developer / Programmer

Free code library:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche

"Gummy" <gumbatman@.hotmail.com> wrote in message
news:122r1dmms96gn1b@.corp.supernews.com...
> S. Justin,
> Thank you for the response. I am using VS 2003 and I was looking for some
> examples or templates so I can get a picture of how this might look.
> Can you recommend any sites, books, etc?
> Thank you.
>
> "S. Justin Gengo" <justin@.[remove to send mail]aboutfortunate.com> wrote
> in
> message news:%23Ab7gjOVGHA.5900@.tk2msftngp13.phx.gbl...
>> Gummy,
>>
>> If you are using Visual Studio 2005 I've been hearing really good things
>> about the new report controls so I'd take a look at those first. I've
>> had
>> decent success using Crystal Reports myself, but they are difficult to
> work
>> with and I've seen lots of posts complaining about them. But still, as I
>> said, they are a viable route to go that I've used successfully.
>>
>> Regards,
>>
>> --
>> S. Justin Gengo
>> Web Developer / Programmer
>>
>> Free code library:
>> http://www.aboutfortunate.com
>>
>> "Out of chaos comes order."
>> Nietzsche
>>
>>
>> "Gummy" <gumbatman@.hotmail.com> wrote in message
>> news:122qp8jljsthd0d@.corp.supernews.com...
>> > Hello,
>>>>> > I am not brand new to .NET, but I'm still a beginner.
>>>>> > We have an Oracle database that nicely compacts (cubes) the data we
>> > need
>> > (think mini-data mart). Unfortunately, this data is currently placed in
>> > about 20 different huge Excel sheets for distribution. Ick!
>>>>> > What I would like to do is have a page that the user sees the different
>> > sections (such as Headcount or Turnover) and can then drill-down into
>> > those
>> > sections (such as by the Area - Northeast, Southeast and by the Level
> such
>> > as Manager or Associate). Then save those settings and next month run
> that
>> > same report with the saved settings. Obviously the data would be
>> > refreshed.
>>>>> > For example:
>>> > TURNOVER
>>> > Northeast
>>> > Managers
>>> > Associates
>>> > HEADCOUNT
>>> > Southwest
>>> > Managers
>>> > Southeast
>>> > Senior Associates
>>> > Associates
>>>>>>>>> > All the data is already compiled it is just a matter of allowing the
> user
>> > to
>> > get to the breakdown of the data they want to see.
>>>>> > Is this possible? Does using Crystal make any sense? Are they any
>> > books,
>> > websites, examples that you'd could recommend to me?
>>>>> > Thank you for the advice and help.
>>>>
>>
Thank you!

"S. Justin Gengo" <justin@.[remove to send mail]aboutfortunate.com> wrote in
message news:ObD7FBQVGHA.4740@.TK2MSFTNGP14.phx.gbl...
> Gummy,
> Sure here are a couple of links to get you started:
> http://aspalliance.com/sql-reporting/
> http://aspalliance.com/crystal/default.aspx
> Sincerely,
> --
> S. Justin Gengo
> Web Developer / Programmer
> Free code library:
> http://www.aboutfortunate.com
> "Out of chaos comes order."
> Nietzsche
>
> "Gummy" <gumbatman@.hotmail.com> wrote in message
> news:122r1dmms96gn1b@.corp.supernews.com...
> > S. Justin,
> > Thank you for the response. I am using VS 2003 and I was looking for
some
> > examples or templates so I can get a picture of how this might look.
> > Can you recommend any sites, books, etc?
> > Thank you.
> > "S. Justin Gengo" <justin@.[remove to send mail]aboutfortunate.com> wrote
> > in
> > message news:%23Ab7gjOVGHA.5900@.tk2msftngp13.phx.gbl...
> >> Gummy,
> >>
> >> If you are using Visual Studio 2005 I've been hearing really good
things
> >> about the new report controls so I'd take a look at those first. I've
> >> had
> >> decent success using Crystal Reports myself, but they are difficult to
> > work
> >> with and I've seen lots of posts complaining about them. But still, as
I
> >> said, they are a viable route to go that I've used successfully.
> >>
> >> Regards,
> >>
> >> --
> >> S. Justin Gengo
> >> Web Developer / Programmer
> >>
> >> Free code library:
> >> http://www.aboutfortunate.com
> >>
> >> "Out of chaos comes order."
> >> Nietzsche
> >>
> >>
> >> "Gummy" <gumbatman@.hotmail.com> wrote in message
> >> news:122qp8jljsthd0d@.corp.supernews.com...
> >> > Hello,
> >> >> >> >> > I am not brand new to .NET, but I'm still a beginner.
> >> >> >> >> > We have an Oracle database that nicely compacts (cubes) the data we
> >> > need
> >> > (think mini-data mart). Unfortunately, this data is currently placed
in
> >> > about 20 different huge Excel sheets for distribution. Ick!
> >> >> >> >> > What I would like to do is have a page that the user sees the
different
> >> > sections (such as Headcount or Turnover) and can then drill-down into
> >> > those
> >> > sections (such as by the Area - Northeast, Southeast and by the Level
> > such
> >> > as Manager or Associate). Then save those settings and next month run
> > that
> >> > same report with the saved settings. Obviously the data would be
> >> > refreshed.
> >> >> >> >> > For example:
> >> >> > TURNOVER
> >> >> > Northeast
> >> >> > Managers
> >> >> > Associates
> >> >> > HEADCOUNT
> >> >> > Southwest
> >> >> > Managers
> >> >> > Southeast
> >> >> > Senior Associates
> >> >> > Associates
> >> >> >> >> >> >> >> >> > All the data is already compiled it is just a matter of allowing the
> > user
> >> > to
> >> > get to the breakdown of the data they want to see.
> >> >> >> >> > Is this possible? Does using Crystal make any sense? Are they any
> >> > books,
> >> > websites, examples that you'd could recommend to me?
> >> >> >> >> > Thank you for the advice and help.
> >> >> >>
> >>

Newbie-ish Question about Building Reports from a Datamart

Hello,
I am not brand new to .NET, but I'm still a beginner.
We have an Oracle database that nicely compacts (cubes) the data we need
(think mini-data mart). Unfortunately, this data is currently placed in
about 20 different huge Excel sheets for distribution. Ick!
What I would like to do is have a page that the user sees the different
sections (such as Headcount or Turnover) and can then drill-down into those
sections (such as by the Area - Northeast, Southeast and by the Level such
as Manager or Associate). Then save those settings and next month run that
same report with the saved settings. Obviously the data would be refreshed.
For example:
TURNOVER
Northeast
Managers
Associates
HEADCOUNT
Southwest
Managers
Southeast
Senior Associates
Associates
All the data is already compiled it is just a matter of allowing the user to
get to the breakdown of the data they want to see.
Is this possible? Does using Crystal make any sense? Are they any books,
websites, examples that you'd could recommend to me?
Thank you for the advice and help.Gummy,
If you are using Visual Studio 2005 I've been hearing really good things
about the new report controls so I'd take a look at those first. I've had
decent success using Crystal Reports myself, but they are difficult to work
with and I've seen lots of posts complaining about them. But still, as I
said, they are a viable route to go that I've used successfully.
Regards,
S. Justin Gengo
Web Developer / Programmer
Free code library:
http://www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Gummy" <gumbatman@.hotmail.com> wrote in message
news:122qp8jljsthd0d@.corp.supernews.com...
> Hello,
>
> I am not brand new to .NET, but I'm still a beginner.
>
> We have an Oracle database that nicely compacts (cubes) the data we need
> (think mini-data mart). Unfortunately, this data is currently placed in
> about 20 different huge Excel sheets for distribution. Ick!
>
> What I would like to do is have a page that the user sees the different
> sections (such as Headcount or Turnover) and can then drill-down into
> those
> sections (such as by the Area - Northeast, Southeast and by the Level such
> as Manager or Associate). Then save those settings and next month run that
> same report with the saved settings. Obviously the data would be
> refreshed.
>
> For example:
> TURNOVER
> Northeast
> Managers
> Associates
> HEADCOUNT
> Southwest
> Managers
> Southeast
> Senior Associates
> Associates
>
>
>
> All the data is already compiled it is just a matter of allowing the user
> to
> get to the breakdown of the data they want to see.
>
> Is this possible? Does using Crystal make any sense? Are they any books,
> websites, examples that you'd could recommend to me?
>
> Thank you for the advice and help.
>
S. Justin,
Thank you for the response. I am using VS 2003 and I was looking for some
examples or templates so I can get a picture of how this might look.
Can you recommend any sites, books, etc?
Thank you.
"S. Justin Gengo" <justin@.[remove to send mail]aboutfortunate.com> wrote in
message news:%23Ab7gjOVGHA.5900@.tk2msftngp13.phx.gbl...
> Gummy,
> If you are using Visual Studio 2005 I've been hearing really good things
> about the new report controls so I'd take a look at those first. I've had
> decent success using Crystal Reports myself, but they are difficult to
work
> with and I've seen lots of posts complaining about them. But still, as I
> said, they are a viable route to go that I've used successfully.
> Regards,
> --
> S. Justin Gengo
> Web Developer / Programmer
> Free code library:
> http://www.aboutfortunate.com
> "Out of chaos comes order."
> Nietzsche
>
> "Gummy" <gumbatman@.hotmail.com> wrote in message
> news:122qp8jljsthd0d@.corp.supernews.com...
such
that
user
>
Gummy,
Sure here are a couple of links to get you started:
http://aspalliance.com/sql-reporting/
http://aspalliance.com/crystal/default.aspx
Sincerely,
S. Justin Gengo
Web Developer / Programmer
Free code library:
http://www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Gummy" <gumbatman@.hotmail.com> wrote in message
news:122r1dmms96gn1b@.corp.supernews.com...
> S. Justin,
> Thank you for the response. I am using VS 2003 and I was looking for some
> examples or templates so I can get a picture of how this might look.
> Can you recommend any sites, books, etc?
> Thank you.
>
> "S. Justin Gengo" <justin@.[remove to send mail]aboutfortunate.com> wrote
> in
> message news:%23Ab7gjOVGHA.5900@.tk2msftngp13.phx.gbl...
> work
> such
> that
> user
>
Thank you!
"S. Justin Gengo" <justin@.[remove to send mail]aboutfortunate.com> wrote in
message news:ObD7FBQVGHA.4740@.TK2MSFTNGP14.phx.gbl...
> Gummy,
> Sure here are a couple of links to get you started:
> http://aspalliance.com/sql-reporting/
> http://aspalliance.com/crystal/default.aspx
> Sincerely,
> --
> S. Justin Gengo
> Web Developer / Programmer
> Free code library:
> http://www.aboutfortunate.com
> "Out of chaos comes order."
> Nietzsche
>
> "Gummy" <gumbatman@.hotmail.com> wrote in message
> news:122r1dmms96gn1b@.corp.supernews.com...
some
things
I
in
different
>

Newbiew use of DropDownList.

Hi,
I think this is the first time I put a dropdownlist in a web form, it
correctly displays the values from the database and when I save the
form I'm able to save the corresponding value to the database. But when
I use the form to display data, the listbox does not automatically
display the value saved in the database of course, so how am I supposed
to make point to the saved value ?Hi,
You can do it one of two ways.
(after ddl is populated)
DropDownList.SelectedIndex =
DropDownList.Items.IndexOf(DropDownList.Items.FindByText(MyDataReader("Field
Name")))
or
(if before ddl is populated)
DropDownList.DataTextField=MyDataReader("FieldName")
I hope this helps.
Mike Douglas
On 26 Mar 2005 16:17:20 -0800, craigkenisston@.hotmail.com wrote:

>Hi,
>I think this is the first time I put a dropdownlist in a web form, it
>correctly displays the values from the database and when I save the
>form I'm able to save the corresponding value to the database. But when
>I use the form to display data, the listbox does not automatically
>display the value saved in the database of course, so how am I supposed
>to make point to the saved value ?

Newbiew use of DropDownList.

Hi,

I think this is the first time I put a dropdownlist in a web form, it
correctly displays the values from the database and when I save the
form I'm able to save the corresponding value to the database. But when
I use the form to display data, the listbox does not automatically
display the value saved in the database of course, so how am I supposed
to make point to the saved value ?Hi,

You can do it one of two ways.

(after ddl is populated)
DropDownList.SelectedIndex =
DropDownList.Items.IndexOf(DropDownList.Items.Find ByText(MyDataReader("FieldName")))

or

(if before ddl is populated)
DropDownList.DataTextField=MyDataReader("FieldName")

I hope this helps.

Mike Douglas

On 26 Mar 2005 16:17:20 -0800, craigkenisston@.hotmail.com wrote:

>Hi,
>I think this is the first time I put a dropdownlist in a web form, it
>correctly displays the values from the database and when I save the
>form I'm able to save the corresponding value to the database. But when
>I use the form to display data, the listbox does not automatically
>display the value saved in the database of course, so how am I supposed
>to make point to the saved value ?

Newby question

Hi

I need help at the very beginning. I have been writing classic ASP for some
time, but getting data out of a SQL database and displaying a single value
eludes me.

So far I have the following code:

Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
Source=SQLServer;Initial Catalog=database;")
Dim myCommand As New SqlDataAdapter("select Name from Products where code =
0117", myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds, "Name")

to get a record out of the database. All I want to do now put the Name in
that record into a variable and use it in the HTML text. I would appreciate
any help.

Thank you
HermannFirst off, the Fill method is a method of the SqlDataAdapter class so to use
Fill, you'd have to create a data adapter first, but you don't need a
dataset for what you're doing. Use the ExecuteScalar() method of the
SqlCommand class to return a single value. Search the framework
documentation for "Obtaining a Single Value from a Database".

In order to use that server side variable in your HTML, do it just as you
would in classic ASP:

<p>Product name for product code 0117 is: <%= myVariable %>.</p
Dale

"Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
> Hi
> I need help at the very beginning. I have been writing classic ASP for
some
> time, but getting data out of a SQL database and displaying a single value
> eludes me.
> So far I have the following code:
> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
> Source=SQLServer;Initial Catalog=database;")
> Dim myCommand As New SqlDataAdapter("select Name from Products where code
=
> 0117", myConnection)
> Dim ds As New DataSet()
> myCommand.Fill(ds, "Name")
> to get a record out of the database. All I want to do now put the Name in
> that record into a variable and use it in the HTML text. I would
appreciate
> any help.
> Thank you
> Hermann
Hello Hermann,

An dataset is probably complete overkill for what you're trying to accomplish here.

Try this:

(c# code, but VB should be pretty similar)
SqlConnection myConnection = new SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial Catalog=database;");
SqlCommand cmd = new SqlCommand("select name from products where code = 0117", myConnection);

string s = (string)cmd.ExecuteScalar();

ExecuteScalar will receive one value from a database. It is up to you to cast it to the appropriate type.

HTH,

--
Matt Berther
http://www.mattberther.com
Hello DalePres,

Dale, in his code example, he was creating a SqlDataAdapter. The variable name was just wrong. ;)

> First off, the Fill method is a method of the SqlDataAdapter class so
> to use Fill, you'd have to create a data adapter first, but you don't
> need a dataset for what you're doing. Use the ExecuteScalar() method
> of the SqlCommand class to return a single value. Search the
> framework documentation for "Obtaining a Single Value from a
> Database".
> In order to use that server side variable in your HTML, do it just as
> you would in classic ASP:
> <p>Product name for product code 0117 is: <%= myVariable %>.</p>
> Dale
> "Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
> news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
>> Hi
>>
>> I need help at the very beginning. I have been writing classic ASP
>> for
>>
> some
>> time, but getting data out of a SQL database and displaying a single
>> value eludes me.
>>
>> So far I have the following code:
>>
>> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
>> Source=SQLServer;Initial Catalog=database;")
>> Dim myCommand As New SqlDataAdapter("select Name from Products where
>> code
> =
>> 0117", myConnection)
>>
>> Dim ds As New DataSet()
>> myCommand.Fill(ds, "Name")
>> to get a record out of the database. All I want to do now put the
>> Name in that record into a variable and use it in the HTML text. I
>> would
>>
> appreciate
>> any help.
>>
>> Thank you
>> Hermann
--

--
Matt Berther
http://www.mattberther.com
You're right. I didn't catch that one at all. I guess that's why variable
naming is so important.

Dale

"Matt Berther" <mberther@.hotmail.com> wrote in message
news:OQF5$FAMEHA.140@.TK2MSFTNGP09.phx.gbl...
> Hello DalePres,
> Dale, in his code example, he was creating a SqlDataAdapter. The variable
name was just wrong. ;)
> > First off, the Fill method is a method of the SqlDataAdapter class so
> > to use Fill, you'd have to create a data adapter first, but you don't
> > need a dataset for what you're doing. Use the ExecuteScalar() method
> > of the SqlCommand class to return a single value. Search the
> > framework documentation for "Obtaining a Single Value from a
> > Database".
> > In order to use that server side variable in your HTML, do it just as
> > you would in classic ASP:
> > <p>Product name for product code 0117 is: <%= myVariable %>.</p>
> > Dale
> > "Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
> > news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
> >> Hi
> >>
> >> I need help at the very beginning. I have been writing classic ASP
> >> for
> >>
> > some
> >> time, but getting data out of a SQL database and displaying a single
> >> value eludes me.
> >>
> >> So far I have the following code:
> >>
> >> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
> >> Source=SQLServer;Initial Catalog=database;")
> >> Dim myCommand As New SqlDataAdapter("select Name from Products where
> >> code
> > =
> >> 0117", myConnection)
> >>
> >> Dim ds As New DataSet()
> >> myCommand.Fill(ds, "Name")
> >> to get a record out of the database. All I want to do now put the
> >> Name in that record into a variable and use it in the HTML text. I
> >> would
> >>
> > appreciate
> >> any help.
> >>
> >> Thank you
> >> Hermann
> --
> --
> Matt Berther
> http://www.mattberther.com
You should look at the Microsoft Data Access Application Block. This
simplifies the process a great deal. In any case, whether you use the
application block or not, if you just want one value, you can use the
ExecuteScalar method of the SQLCommand class to readily return it, or the
equivalent method of the SQLHelper class defined in the Data Access
Application Block.

Take a look at
http://www.microsoft.com/resources/...diences.asp#dev

Scroll down a ways, and you'll find a link to the Data Access Application
Block, as well as a wealth of other useful information.

"Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
> Hi
> I need help at the very beginning. I have been writing classic ASP for
some
> time, but getting data out of a SQL database and displaying a single value
> eludes me.
> So far I have the following code:
> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
> Source=SQLServer;Initial Catalog=database;")
> Dim myCommand As New SqlDataAdapter("select Name from Products where code
=
> 0117", myConnection)
> Dim ds As New DataSet()
> myCommand.Fill(ds, "Name")
> to get a record out of the database. All I want to do now put the Name in
> that record into a variable and use it in the HTML text. I would
appreciate
> any help.
> Thank you
> Hermann
Hi

Thanks for your help. The code example comes straight out of a tutorial on
asp.net!

Unfortunately, I do not at this time have the leisure to learn the ins and
outs of the .net methods. All I need is the equivalent code to:

Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "dbname","username","password"

Query = "Select * from links Where ID = '" & id & "'"
Set RS = Connect.Execute(Query) <-- I thought this is the dataset

code = RS("code")
title = RS("title")
url = RS("url")
email = RS("email")
description = RS("description")
retlink = RS("retlink")

I would be very thankful if someone could help me write a the code to do the
same thing under .net.

Thanks
Hermann

"Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
> Hi
> I need help at the very beginning. I have been writing classic ASP for
some
> time, but getting data out of a SQL database and displaying a single value
> eludes me.
> So far I have the following code:
> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
> Source=SQLServer;Initial Catalog=database;")
> Dim myCommand As New SqlDataAdapter("select Name from Products where code
=
> 0117", myConnection)
> Dim ds As New DataSet()
> myCommand.Fill(ds, "Name")
> to get a record out of the database. All I want to do now put the Name in
> that record into a variable and use it in the HTML text. I would
appreciate
> any help.
> Thank you
> Hermann
Hello Hermann,

SqlConnection myConnection = new SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial Catalog=database;");

SqlCommand cmd = new SqlCommand("select name from products where code = 0117", myConnection);

using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection) )
{
rdr.Read(); // if you want to loop through records, sorround this with a while block

string code = rdr["code"].ToString();
string title = rdr["title"].ToString();
string url = rdr["url"].ToString();
string email = rdr["email"].ToString();
string description = rdr["description"].ToString();
string retlink = rdr["retlink"].ToString();
}

> Hi
> Thanks for your help. The code example comes straight out of a
> tutorial on asp.net!
> Unfortunately, I do not at this time have the leisure to learn the ins
> and outs of the .net methods. All I need is the equivalent code to:
> Set Connect = Server.CreateObject("ADODB.Connection")
> Connect.Open "dbname","username","password"
> Query = "Select * from links Where ID = '" & id & "'"
> Set RS = Connect.Execute(Query) <-- I thought this is the dataset
> code = RS("code")
> title = RS("title")
> url = RS("url")
> email = RS("email")
> description = RS("description")
> retlink = RS("retlink")
> I would be very thankful if someone could help me write a the code to
> do the same thing under .net.
> Thanks
> Hermann
> "Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
> news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
>> Hi
>>
>> I need help at the very beginning. I have been writing classic ASP
>> for
>>
> some
>> time, but getting data out of a SQL database and displaying a single
>> value eludes me.
>>
>> So far I have the following code:
>>
>> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
>> Source=SQLServer;Initial Catalog=database;")
>> Dim myCommand As New SqlDataAdapter("select Name from Products where
>> code
> =
>> 0117", myConnection)
>>
>> Dim ds As New DataSet()
>> myCommand.Fill(ds, "Name")
>> to get a record out of the database. All I want to do now put the
>> Name in that record into a variable and use it in the HTML text. I
>> would
>>
> appreciate
>> any help.
>>
>> Thank you
>> Hermann
--

--
Matt Berther
http://www.mattberther.com
Hi
Much Thanks for the code. I placed on a test page with the correct
variables, but received this error message:

Compiler Error Message: BC30684: 'SqlConnection' is a type and cannot be
used as an expression

I have the following lines at the top of the page:

<%@. import Namespace="System.Data" %>
<%@. import Namespace="System.Data.SqlClient" %
Do I need to add anything else?
Thanks again
Hermann

"Matt Berther" <mberther@.hotmail.com> wrote in message
news:ONNBoITMEHA.2532@.TK2MSFTNGP10.phx.gbl...
> Hello Hermann,
> SqlConnection myConnection = new
SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
Catalog=database;");
> SqlCommand cmd = new SqlCommand("select name from products where code =
0117", myConnection);
> using (IDataReader rdr =
cmd.ExecuteReader(CommandBehavior.CloseConnection) )
> {
> rdr.Read(); // if you want to loop through records, sorround this with
a while block
> string code = rdr["code"].ToString();
> string title = rdr["title"].ToString();
> string url = rdr["url"].ToString();
> string email = rdr["email"].ToString();
> string description = rdr["description"].ToString();
> string retlink = rdr["retlink"].ToString();
> }
> > Hi
> > Thanks for your help. The code example comes straight out of a
> > tutorial on asp.net!
> > Unfortunately, I do not at this time have the leisure to learn the ins
> > and outs of the .net methods. All I need is the equivalent code to:
> > Set Connect = Server.CreateObject("ADODB.Connection")
> > Connect.Open "dbname","username","password"
> > Query = "Select * from links Where ID = '" & id & "'"
> > Set RS = Connect.Execute(Query) <-- I thought this is the dataset
> > code = RS("code")
> > title = RS("title")
> > url = RS("url")
> > email = RS("email")
> > description = RS("description")
> > retlink = RS("retlink")
> > I would be very thankful if someone could help me write a the code to
> > do the same thing under .net.
> > Thanks
> > Hermann
> > "Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
> > news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
> >> Hi
> >>
> >> I need help at the very beginning. I have been writing classic ASP
> >> for
> >>
> > some
> >> time, but getting data out of a SQL database and displaying a single
> >> value eludes me.
> >>
> >> So far I have the following code:
> >>
> >> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
> >> Source=SQLServer;Initial Catalog=database;")
> >> Dim myCommand As New SqlDataAdapter("select Name from Products where
> >> code
> > =
> >> 0117", myConnection)
> >>
> >> Dim ds As New DataSet()
> >> myCommand.Fill(ds, "Name")
> >> to get a record out of the database. All I want to do now put the
> >> Name in that record into a variable and use it in the HTML text. I
> >> would
> >>
> > appreciate
> >> any help.
> >>
> >> Thank you
> >> Hermann
> --
> --
> Matt Berther
> http://www.mattberther.com
Hello Hermann,

Try putting this in the .cs code-behind file in Page_Load.

> Hi
> Much Thanks for the code. I placed on a test page with the correct
> variables, but received this error message:
> Compiler Error Message: BC30684: 'SqlConnection' is a type and cannot
> be used as an expression
> I have the following lines at the top of the page:
> <%@. import Namespace="System.Data" %>
> <%@. import Namespace="System.Data.SqlClient" %>
> Do I need to add anything else?
> Thanks again
> Hermann
> "Matt Berther" <mberther@.hotmail.com> wrote in message
> news:ONNBoITMEHA.2532@.TK2MSFTNGP10.phx.gbl...
>> Hello Hermann,
>>
>> SqlConnection myConnection = new
>>
> SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
> Catalog=database;");
>> SqlCommand cmd = new SqlCommand("select name from products where code
>> =
>>
> 0117", myConnection);
>> using (IDataReader rdr =
>>
> cmd.ExecuteReader(CommandBehavior.CloseConnection) )
>> {
>> rdr.Read(); // if you want to loop through records, sorround this
>> with
> a while block
>> string code = rdr["code"].ToString();
>> string title = rdr["title"].ToString();
>> string url = rdr["url"].ToString();
>> string email = rdr["email"].ToString();
>> string description = rdr["description"].ToString();
>> string retlink = rdr["retlink"].ToString();
>> }
>>> Hi
>>>
>>> Thanks for your help. The code example comes straight out of a
>>> tutorial on asp.net!
>>>
>>> Unfortunately, I do not at this time have the leisure to learn the
>>> ins and outs of the .net methods. All I need is the equivalent code
>>> to:
>>>
>>> Set Connect = Server.CreateObject("ADODB.Connection")
>>> Connect.Open "dbname","username","password"
>>> Query = "Select * from links Where ID = '" & id & "'"
>>> Set RS = Connect.Execute(Query) <-- I thought this is the dataset
>>> code = RS("code")
>>> title = RS("title")
>>> url = RS("url")
>>> email = RS("email")
>>> description = RS("description")
>>> retlink = RS("retlink")
>>> I would be very thankful if someone could help me write a the code
>>> to
>>> do the same thing under .net.
>>> Thanks
>>> Hermann
>>> "Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
>>> news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
>>>> Hi
>>>>
>>>> I need help at the very beginning. I have been writing classic ASP
>>>> for
>>>>
>>> some
>>>
>>>> time, but getting data out of a SQL database and displaying a
>>>> single value eludes me.
>>>>
>>>> So far I have the following code:
>>>>
>>>> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
>>>> Source=SQLServer;Initial Catalog=database;")
>>>> Dim myCommand As New SqlDataAdapter("select Name from Products
>>>> where
>>>> code
>>> =
>>>
>>>> 0117", myConnection)
>>>>
>>>> Dim ds As New DataSet()
>>>> myCommand.Fill(ds, "Name")
>>>> to get a record out of the database. All I want to do now put the
>>>> Name in that record into a variable and use it in the HTML text. I
>>>> would
>>> appreciate
>>>
>>>> any help.
>>>>
>>>> Thank you
>>>> Hermann
>> --
>>
>> --
>> Matt Berther
>> http://www.mattberther.com
--

--
Matt Berther
http://www.mattberther.com
Hi

Can you explain what you mean with "Page_Load"?
Thanks
Hermann

"Matt Berther" <mberther@.hotmail.com> wrote in message
news:%23C6uZOaMEHA.644@.tk2msftngp13.phx.gbl...
> Hello Hermann,
> Try putting this in the .cs code-behind file in Page_Load.
> > Hi
> > Much Thanks for the code. I placed on a test page with the correct
> > variables, but received this error message:
> > Compiler Error Message: BC30684: 'SqlConnection' is a type and cannot
> > be used as an expression
> > I have the following lines at the top of the page:
> > <%@. import Namespace="System.Data" %>
> > <%@. import Namespace="System.Data.SqlClient" %>
> > Do I need to add anything else?
> > Thanks again
> > Hermann
> > "Matt Berther" <mberther@.hotmail.com> wrote in message
> > news:ONNBoITMEHA.2532@.TK2MSFTNGP10.phx.gbl...
> >> Hello Hermann,
> >>
> >> SqlConnection myConnection = new
> >>
> > SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
> > Catalog=database;");
> >> SqlCommand cmd = new SqlCommand("select name from products where code
> >> =
> >>
> > 0117", myConnection);
> >> using (IDataReader rdr =
> >>
> > cmd.ExecuteReader(CommandBehavior.CloseConnection) )
> >> {
> >> rdr.Read(); // if you want to loop through records, sorround this
> >> with
> > a while block
> >> string code = rdr["code"].ToString();
> >> string title = rdr["title"].ToString();
> >> string url = rdr["url"].ToString();
> >> string email = rdr["email"].ToString();
> >> string description = rdr["description"].ToString();
> >> string retlink = rdr["retlink"].ToString();
> >> }
> >>> Hi
> >>>
> >>> Thanks for your help. The code example comes straight out of a
> >>> tutorial on asp.net!
> >>>
> >>> Unfortunately, I do not at this time have the leisure to learn the
> >>> ins and outs of the .net methods. All I need is the equivalent code
> >>> to:
> >>>
> >>> Set Connect = Server.CreateObject("ADODB.Connection")
> >>> Connect.Open "dbname","username","password"
> >>> Query = "Select * from links Where ID = '" & id & "'"
> >>> Set RS = Connect.Execute(Query) <-- I thought this is the dataset
> >>> code = RS("code")
> >>> title = RS("title")
> >>> url = RS("url")
> >>> email = RS("email")
> >>> description = RS("description")
> >>> retlink = RS("retlink")
> >>> I would be very thankful if someone could help me write a the code
> >>> to
> >>> do the same thing under .net.
> >>> Thanks
> >>> Hermann
> >>> "Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
> >>> news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
> >>>> Hi
> >>>>
> >>>> I need help at the very beginning. I have been writing classic ASP
> >>>> for
> >>>>
> >>> some
> >>>
> >>>> time, but getting data out of a SQL database and displaying a
> >>>> single value eludes me.
> >>>>
> >>>> So far I have the following code:
> >>>>
> >>>> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
> >>>> Source=SQLServer;Initial Catalog=database;")
> >>>> Dim myCommand As New SqlDataAdapter("select Name from Products
> >>>> where
> >>>> code
> >>> =
> >>>
> >>>> 0117", myConnection)
> >>>>
> >>>> Dim ds As New DataSet()
> >>>> myCommand.Fill(ds, "Name")
> >>>> to get a record out of the database. All I want to do now put the
> >>>> Name in that record into a variable and use it in the HTML text. I
> >>>> would
> >>> appreciate
> >>>
> >>>> any help.
> >>>>
> >>>> Thank you
> >>>> Hermann
> >> --
> >>
> >> --
> >> Matt Berther
> >> http://www.mattberther.com
> --
> --
> Matt Berther
> http://www.mattberther.com
there is a Page_Load event, which you can implement. I believe he wants you
to put the code he provided into that event handler.

private void Page_Load (object sender, System.EventArgs e)
{
// your code here
}

this is part of the 'code behind' technology in ASP.net.

hope that helps,
sincerely,
J

"Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
news:eQCc71jMEHA.3972@.TK2MSFTNGP10.phx.gbl...
> Hi
> Can you explain what you mean with "Page_Load"?
> Thanks
> Hermann
> "Matt Berther" <mberther@.hotmail.com> wrote in message
> news:%23C6uZOaMEHA.644@.tk2msftngp13.phx.gbl...
> > Hello Hermann,
> > Try putting this in the .cs code-behind file in Page_Load.
> > > Hi
> > > Much Thanks for the code. I placed on a test page with the correct
> > > variables, but received this error message:
> > > Compiler Error Message: BC30684: 'SqlConnection' is a type and cannot
> > > be used as an expression
> > > > I have the following lines at the top of the page:
> > > > <%@. import Namespace="System.Data" %>
> > > <%@. import Namespace="System.Data.SqlClient" %>
> > > Do I need to add anything else?
> > > Thanks again
> > > Hermann
> > > "Matt Berther" <mberther@.hotmail.com> wrote in message
> > > news:ONNBoITMEHA.2532@.TK2MSFTNGP10.phx.gbl...
> > > >> Hello Hermann,
> > >>
> > >> SqlConnection myConnection = new
> > >>
> > > SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
> > > Catalog=database;");
> > > >> SqlCommand cmd = new SqlCommand("select name from products where code
> > >> =
> > >>
> > > 0117", myConnection);
> > > >> using (IDataReader rdr =
> > >>
> > > cmd.ExecuteReader(CommandBehavior.CloseConnection) )
> > > >> {
> > >> rdr.Read(); // if you want to loop through records, sorround this
> > >> with
> > > a while block
> > > >> string code = rdr["code"].ToString();
> > >> string title = rdr["title"].ToString();
> > >> string url = rdr["url"].ToString();
> > >> string email = rdr["email"].ToString();
> > >> string description = rdr["description"].ToString();
> > >> string retlink = rdr["retlink"].ToString();
> > >> }
> > >>> Hi
> > >>>
> > >>> Thanks for your help. The code example comes straight out of a
> > >>> tutorial on asp.net!
> > >>>
> > >>> Unfortunately, I do not at this time have the leisure to learn the
> > >>> ins and outs of the .net methods. All I need is the equivalent code
> > >>> to:
> > >>>
> > >>> Set Connect = Server.CreateObject("ADODB.Connection")
> > >>> Connect.Open "dbname","username","password"
> > >>> Query = "Select * from links Where ID = '" & id & "'"
> > >>> Set RS = Connect.Execute(Query) <-- I thought this is the dataset
> > >>> code = RS("code")
> > >>> title = RS("title")
> > >>> url = RS("url")
> > >>> email = RS("email")
> > >>> description = RS("description")
> > >>> retlink = RS("retlink")
> > >>> I would be very thankful if someone could help me write a the code
> > >>> to
> > >>> do the same thing under .net.
> > >>> Thanks
> > >>> Hermann
> > >>> "Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
> > >>> news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
> > >>>> Hi
> > >>>>
> > >>>> I need help at the very beginning. I have been writing classic ASP
> > >>>> for
> > >>>>
> > >>> some
> > >>>
> > >>>> time, but getting data out of a SQL database and displaying a
> > >>>> single value eludes me.
> > >>>>
> > >>>> So far I have the following code:
> > >>>>
> > >>>> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
> > >>>> Source=SQLServer;Initial Catalog=database;")
> > >>>> Dim myCommand As New SqlDataAdapter("select Name from Products
> > >>>> where
> > >>>> code
> > >>> =
> > >>>
> > >>>> 0117", myConnection)
> > >>>>
> > >>>> Dim ds As New DataSet()
> > >>>> myCommand.Fill(ds, "Name")
> > >>>> to get a record out of the database. All I want to do now put the
> > >>>> Name in that record into a variable and use it in the HTML text. I
> > >>>> would
> > >>> appreciate
> > >>>
> > >>>> any help.
> > >>>>
> > >>>> Thank you
> > >>>> Hermann
> > >> --
> > >>
> > >> --
> > >> Matt Berther
> > >> http://www.mattberther.com
> > --
> > --
> > Matt Berther
> > http://www.mattberther.com
Hello John,

Thanks. That is exactly what I meant...

> there is a Page_Load event, which you can implement. I believe he
> wants you to put the code he provided into that event handler.
> private void Page_Load (object sender, System.EventArgs e)
> {
> // your code here
> }
> this is part of the 'code behind' technology in ASP.net.
> hope that helps,
> sincerely,
> J
> "Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
> news:eQCc71jMEHA.3972@.TK2MSFTNGP10.phx.gbl...
>> Hi
>>
>> Can you explain what you mean with "Page_Load"?
>> Thanks
>> Hermann
>> "Matt Berther" <mberther@.hotmail.com> wrote in message
>> news:%23C6uZOaMEHA.644@.tk2msftngp13.phx.gbl...
>>
>>> Hello Hermann,
>>>
>>> Try putting this in the .cs code-behind file in Page_Load.
>>>
>>>> Hi
>>>> Much Thanks for the code. I placed on a test page with the correct
>>>> variables, but received this error message:
>>>> Compiler Error Message: BC30684: 'SqlConnection' is a type and
>>>> cannot
>>>> be used as an expression
>>>> I have the following lines at the top of the page:
>>>>
>>>> <%@. import Namespace="System.Data" %>
>>>> <%@. import Namespace="System.Data.SqlClient" %>
>>>> Do I need to add anything else?
>>>> Thanks again
>>>> Hermann
>>>> "Matt Berther" <mberther@.hotmail.com> wrote in message
>>>> news:ONNBoITMEHA.2532@.TK2MSFTNGP10.phx.gbl...
>>>>> Hello Hermann,
>>>>>
>>>>> SqlConnection myConnection = new
>>>>>
>>>> SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
>>>> Catalog=database;");
>>>>
>>>>> SqlCommand cmd = new SqlCommand("select name from products where
>>>>> code =
>>>>>
>>>> 0117", myConnection);
>>>>
>>>>> using (IDataReader rdr =
>>>>>
>>>> cmd.ExecuteReader(CommandBehavior.CloseConnection) )
>>>>
>>>>> {
>>>>> rdr.Read(); // if you want to loop through records, sorround this
>>>>> with
>>>> a while block
>>>>
>>>>> string code = rdr["code"].ToString();
>>>>> string title = rdr["title"].ToString();
>>>>> string url = rdr["url"].ToString();
>>>>> string email = rdr["email"].ToString();
>>>>> string description = rdr["description"].ToString();
>>>>> string retlink = rdr["retlink"].ToString();
>>>>> }
>>>>>> Hi
>>>>>>
>>>>>> Thanks for your help. The code example comes straight out of a
>>>>>> tutorial on asp.net!
>>>>>>
>>>>>> Unfortunately, I do not at this time have the leisure to learn
>>>>>> the ins and outs of the .net methods. All I need is the
>>>>>> equivalent code to:
>>>>>>
>>>>>> Set Connect = Server.CreateObject("ADODB.Connection")
>>>>>> Connect.Open "dbname","username","password"
>>>>>> Query = "Select * from links Where ID = '" & id & "'"
>>>>>> Set RS = Connect.Execute(Query) <-- I thought this is the dataset
>>>>>> code = RS("code")
>>>>>> title = RS("title")
>>>>>> url = RS("url")
>>>>>> email = RS("email")
>>>>>> description = RS("description")
>>>>>> retlink = RS("retlink")
>>>>>> I would be very thankful if someone could help me write a the
>>>>>> code
>>>>>> to
>>>>>> do the same thing under .net.
>>>>>> Thanks
>>>>>> Hermann
>>>>>> "Hermann W Ehlers" <hermann@.AThawkspoint.com> wrote in message
>>>>>> news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
>>>>>>> Hi
>>>>>>>
>>>>>>> I need help at the very beginning. I have been writing classic
>>>>>>> ASP for
>>>>>>>
>>>>>> some
>>>>>>
>>>>>>> time, but getting data out of a SQL database and displaying a
>>>>>>> single value eludes me.
>>>>>>>
>>>>>>> So far I have the following code:
>>>>>>>
>>>>>>> Dim myConnection As New
>>>>>>> SqlConnection("UID=dbuser;PWD=thepass;Data
>>>>>>> Source=SQLServer;Initial Catalog=database;")
>>>>>>> Dim myCommand As New SqlDataAdapter("select Name from Products
>>>>>>> where
>>>>>>> code
>>>>>> =
>>>>>>
>>>>>>> 0117", myConnection)
>>>>>>>
>>>>>>> Dim ds As New DataSet()
>>>>>>> myCommand.Fill(ds, "Name")
>>>>>>> to get a record out of the database. All I want to do now put
>>>>>>> the
>>>>>>> Name in that record into a variable and use it in the HTML text.
>>>>>>> I
>>>>>>> would
>>>>>> appreciate
>>>>>>
>>>>>>> any help.
>>>>>>>
>>>>>>> Thank you
>>>>>>> Hermann
>>>>> --
>>>>>
>>>>> --
>>>>> Matt Berther
>>>>> http://www.mattberther.com
>>> --
>>>
>>> --
>>> Matt Berther
>>> http://www.mattberther.com
--

--
Matt Berther
http://www.mattberther.com