Showing posts with label procedures. Show all posts
Showing posts with label procedures. Show all posts

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--------------

Saturday, March 24, 2012

Newbie:please help me 'display' this on a simple .aspx page

I understand that store procedures are the recommended way to handle SQL
queries from an ASP application. However I am working on a small academic
assignment and I just need to get this over with. I created the store
procedure but now the teacher didn't accept that, as he is concerned he
would need to install the store procedure in Query Analyzer from his end.
Can you please clarify how I would be to do the following using a Select
Statement (VB.NET, ASP.NET 2.0):
Dim myNextPage
myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
Dim myString
myString = "SELECT Employee From Pubs " _
& "WHERE job_id = " & TxtBox1.Text And
& "WHERE employee_name = " & TxtBox2.Text And
& "WHERE hire_date = " & TxtBox3.Text
'Now I want to:
If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
(hire_date = TxtBox3.Text) Then
Response.Redirect("myNextPage")
'Then on Next page I would like to display label.Text = "Your
information matched and I can go ahead to reset your password in AD..."
'However doing:
label.Text = "Your info matched and I can go ahead and reset your
password in AD..." ' This wouldn't work. Where do I need to put this
Label.Text ="..." ?
Else
Response.Redirect("myNextPage")
'Display on next page Label.Text = "The phrase(s) you typed didn't
match. Please click back button and resubmit info."
'If possible, I would like to display all phrases that did not match
in 'myNextPage', so that user would know which ones he didn't answer
correctly.
End If
End SubIn that case u may choose to write all logic of stored procedure in asp.net
itsself.
-jignesh
www.dotnetjini.com
"Marlon Brown" <marlon_brownj@.hotmail.com> wrote in message
news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl...
> I understand that store procedures are the recommended way to handle SQL
> queries from an ASP application. However I am working on a small academic
> assignment and I just need to get this over with. I created the store
> procedure but now the teacher didn't accept that, as he is concerned he
> would need to install the store procedure in Query Analyzer from his end.
> Can you please clarify how I would be to do the following using a Select
> Statement (VB.NET, ASP.NET 2.0):
>
> Dim myNextPage
> myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
> Dim myString
> myString = "SELECT Employee From Pubs " _
> & "WHERE job_id = " & TxtBox1.Text And
> & "WHERE employee_name = " & TxtBox2.Text And
> & "WHERE hire_date = " & TxtBox3.Text
> 'Now I want to:
> If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
> (hire_date = TxtBox3.Text) Then
> Response.Redirect("myNextPage")
> 'Then on Next page I would like to display label.Text = "Your
> information matched and I can go ahead to reset your password in AD..."
> 'However doing:
> label.Text = "Your info matched and I can go ahead and reset your
> password in AD..." ' This wouldn't work. Where do I need to put this
> Label.Text ="..." ?
> Else
> Response.Redirect("myNextPage")
> 'Display on next page Label.Text = "The phrase(s) you typed didn't
> match. Please click back button and resubmit info."
> 'If possible, I would like to display all phrases that did not match
> in 'myNextPage', so that user would know which ones he didn't answer
> correctly.
> End If
> End Sub
>
Ok, if you can't show me the SQL part OK, but could you help me with on how
to display whatever variable I capture from the SQL query on .ASP.NET ?
I tried to use Response.Write(TextBox1.Text) but that didn't returned
satisfactory results. I understand I shouldn't use Response.Write and
therefore I attempted to create a Label1.Text to display whatever
information I got from SQL. The problem is that I do Label1.Text =
InfoFromSQL and that doesn't work either. It returns nothing on the
Label1.Text.
'Then on Next page I would like to display label.Text = "Your
'information matched and I can go ahead to reset your password in AD..."
' 'However doing:
' label.Text = "Your info matched and I can go ahead and reset your
' password in AD..." ' This wouldn't work. Where do I need to put this
' Label.Text ="..." ?
I am trying to
"Jignesh Desai" <jignesh_desai@.hotmail.com> wrote in message
news:O8z%238QhJFHA.2356@.TK2MSFTNGP14.phx.gbl...
> In that case u may choose to write all logic of stored procedure in
> asp.net
> itsself.
> -jignesh
> www.dotnetjini.com
> "Marlon Brown" <marlon_brownj@.hotmail.com> wrote in message
> news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl...
>
Labels do not produce actual HTML control on the client-side so have no way
to postback to the server. I believe you can store you texts in Session
variable.
Session["yourmsg"] = "Your info matched and I can go ahead and reset your
password in AD..."
Then in the other page:
label.Text = CStr(Session["yourmsg"])
You may use Session variable to store anything, including ArrayList and
access it on other pages in the same session. Just rememeber to CType it
back when you retrieve it.
"Marlon Brown" <marlon_brownj@.hotmail.com> bl
news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl g...
> I understand that store procedures are the recommended way to handle SQL
> queries from an ASP application. However I am working on a small academic
> assignment and I just need to get this over with. I created the store
> procedure but now the teacher didn't accept that, as he is concerned he
> would need to install the store procedure in Query Analyzer from his end.
> Can you please clarify how I would be to do the following using a Select
> Statement (VB.NET, ASP.NET 2.0):
>
> Dim myNextPage
> myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
> Dim myString
> myString = "SELECT Employee From Pubs " _
> & "WHERE job_id = " & TxtBox1.Text And
> & "WHERE employee_name = " & TxtBox2.Text And
> & "WHERE hire_date = " & TxtBox3.Text
> 'Now I want to:
> If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
> (hire_date = TxtBox3.Text) Then
> Response.Redirect("myNextPage")
> 'Then on Next page I would like to display label.Text = "Your
> information matched and I can go ahead to reset your password in AD..."
> 'However doing:
> label.Text = "Your info matched and I can go ahead and reset your
> password in AD..." ' This wouldn't work. Where do I need to put this
> Label.Text ="..." ?
> Else
> Response.Redirect("myNextPage")
> 'Display on next page Label.Text = "The phrase(s) you typed didn't
> match. Please click back button and resubmit info."
> 'If possible, I would like to display all phrases that did not match
> in 'myNextPage', so that user would know which ones he didn't answer
> correctly.
> End If
> End Sub
>

Newbie:please help me display this on a simple .aspx page

I understand that store procedures are the recommended way to handle SQL
queries from an ASP application. However I am working on a small academic
assignment and I just need to get this over with. I created the store
procedure but now the teacher didn't accept that, as he is concerned he
would need to install the store procedure in Query Analyzer from his end.
Can you please clarify how I would be to do the following using a Select
Statement (VB.NET, ASP.NET 2.0):

Dim myNextPage
myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.

Dim myString
myString = "SELECT Employee From Pubs " _
& "WHERE job_id = " & TxtBox1.Text And
& "WHERE employee_name = " & TxtBox2.Text And
& "WHERE hire_date = " & TxtBox3.Text

'Now I want to:
If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
(hire_date = TxtBox3.Text) Then
Response.Redirect("myNextPage")
'Then on Next page I would like to display label.Text = "Your
information matched and I can go ahead to reset your password in AD..."
'However doing:
label.Text = "Your info matched and I can go ahead and reset your
password in AD..." ' This wouldn't work. Where do I need to put this
Label.Text ="..." ?

Else
Response.Redirect("myNextPage")
'Display on next page Label.Text = "The phrase(s) you typed didn't
match. Please click back button and resubmit info."
'If possible, I would like to display all phrases that did not match
in 'myNextPage', so that user would know which ones he didn't answer
correctly.

End If

End SubIn that case u may choose to write all logic of stored procedure in asp.net
itsself.

-jignesh
www.dotnetjini.com

"Marlon Brown" <marlon_brownj@.hotmail.com> wrote in message
news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl...
> I understand that store procedures are the recommended way to handle SQL
> queries from an ASP application. However I am working on a small academic
> assignment and I just need to get this over with. I created the store
> procedure but now the teacher didn't accept that, as he is concerned he
> would need to install the store procedure in Query Analyzer from his end.
> Can you please clarify how I would be to do the following using a Select
> Statement (VB.NET, ASP.NET 2.0):
>
> Dim myNextPage
> myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
> Dim myString
> myString = "SELECT Employee From Pubs " _
> & "WHERE job_id = " & TxtBox1.Text And
> & "WHERE employee_name = " & TxtBox2.Text And
> & "WHERE hire_date = " & TxtBox3.Text
> 'Now I want to:
> If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
> (hire_date = TxtBox3.Text) Then
> Response.Redirect("myNextPage")
> 'Then on Next page I would like to display label.Text = "Your
> information matched and I can go ahead to reset your password in AD..."
> 'However doing:
> label.Text = "Your info matched and I can go ahead and reset your
> password in AD..." ' This wouldn't work. Where do I need to put this
> Label.Text ="..." ?
> Else
> Response.Redirect("myNextPage")
> 'Display on next page Label.Text = "The phrase(s) you typed didn't
> match. Please click back button and resubmit info."
> 'If possible, I would like to display all phrases that did not match
> in 'myNextPage', so that user would know which ones he didn't answer
> correctly.
> End If
> End Sub
Ok, if you can't show me the SQL part OK, but could you help me with on how
to display whatever variable I capture from the SQL query on .ASP.NET ?
I tried to use Response.Write(TextBox1.Text) but that didn't returned
satisfactory results. I understand I shouldn't use Response.Write and
therefore I attempted to create a Label1.Text to display whatever
information I got from SQL. The problem is that I do Label1.Text =
InfoFromSQL and that doesn't work either. It returns nothing on the
Label1.Text.

'Then on Next page I would like to display label.Text = "Your
'information matched and I can go ahead to reset your password in AD..."
' 'However doing:
' label.Text = "Your info matched and I can go ahead and reset your
' password in AD..." ' This wouldn't work. Where do I need to put this
' Label.Text ="..." ?

I am trying to
"Jignesh Desai" <jignesh_desai@.hotmail.com> wrote in message
news:O8z%238QhJFHA.2356@.TK2MSFTNGP14.phx.gbl...
> In that case u may choose to write all logic of stored procedure in
> asp.net
> itsself.
> -jignesh
> www.dotnetjini.com
> "Marlon Brown" <marlon_brownj@.hotmail.com> wrote in message
> news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl...
>> I understand that store procedures are the recommended way to handle SQL
>> queries from an ASP application. However I am working on a small academic
>> assignment and I just need to get this over with. I created the store
>> procedure but now the teacher didn't accept that, as he is concerned he
>> would need to install the store procedure in Query Analyzer from his end.
>> Can you please clarify how I would be to do the following using a Select
>> Statement (VB.NET, ASP.NET 2.0):
>>
>>
>>
>> Dim myNextPage
>> myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
>>
>> Dim myString
>> myString = "SELECT Employee From Pubs " _
>> & "WHERE job_id = " & TxtBox1.Text And
>> & "WHERE employee_name = " & TxtBox2.Text
>> And
>> & "WHERE hire_date = " & TxtBox3.Text
>>
>> 'Now I want to:
>> If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
>> (hire_date = TxtBox3.Text) Then
>> Response.Redirect("myNextPage")
>> 'Then on Next page I would like to display label.Text = "Your
>> information matched and I can go ahead to reset your password in AD..."
>> 'However doing:
>> label.Text = "Your info matched and I can go ahead and reset your
>> password in AD..." ' This wouldn't work. Where do I need to put this
>> Label.Text ="..." ?
>>
>> Else
>> Response.Redirect("myNextPage")
>> 'Display on next page Label.Text = "The phrase(s) you typed didn't
>> match. Please click back button and resubmit info."
>> 'If possible, I would like to display all phrases that did not
>> match
>> in 'myNextPage', so that user would know which ones he didn't answer
>> correctly.
>>
>> End If
>>
>> End Sub
>>
>>
Labels do not produce actual HTML control on the client-side so have no way
to postback to the server. I believe you can store you texts in Session
variable.

Session["yourmsg"] = "Your info matched and I can go ahead and reset your
password in AD..."

Then in the other page:
label.Text = CStr(Session["yourmsg"])

You may use Session variable to store anything, including ArrayList and
access it on other pages in the same session. Just rememeber to CType it
back when you retrieve it.

"Marlon Brown" <marlon_brownj@.hotmail.com> bl
news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl g...
> I understand that store procedures are the recommended way to handle SQL
> queries from an ASP application. However I am working on a small academic
> assignment and I just need to get this over with. I created the store
> procedure but now the teacher didn't accept that, as he is concerned he
> would need to install the store procedure in Query Analyzer from his end.
> Can you please clarify how I would be to do the following using a Select
> Statement (VB.NET, ASP.NET 2.0):
>
> Dim myNextPage
> myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
> Dim myString
> myString = "SELECT Employee From Pubs " _
> & "WHERE job_id = " & TxtBox1.Text And
> & "WHERE employee_name = " & TxtBox2.Text And
> & "WHERE hire_date = " & TxtBox3.Text
> 'Now I want to:
> If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
> (hire_date = TxtBox3.Text) Then
> Response.Redirect("myNextPage")
> 'Then on Next page I would like to display label.Text = "Your
> information matched and I can go ahead to reset your password in AD..."
> 'However doing:
> label.Text = "Your info matched and I can go ahead and reset your
> password in AD..." ' This wouldn't work. Where do I need to put this
> Label.Text ="..." ?
> Else
> Response.Redirect("myNextPage")
> 'Display on next page Label.Text = "The phrase(s) you typed didn't
> match. Please click back button and resubmit info."
> 'If possible, I would like to display all phrases that did not match
> in 'myNextPage', so that user would know which ones he didn't answer
> correctly.
> End If
> End Sub