I am beginning aspNet, I know well win apps.
Need a simple and schematic code example to start work.
This is what I need to accomplish:
----------------------
Given button and a TextBox on a web form when one presses the button on
the web form on a client pc, the sql query which is contained in the
text box is sent to a vb net application on a server pc. The win
application sends the query to the database, collects the results,
creates a web page showing some of these result and send the page back
to the browser (for future queries).
1. client (Browser, IE) ----> WinApp on a Server pc ----> Database
2. Database --> WinApp on Server pc --> create NewAspPage --> client
pc (Browser)
----------------------
I am kind of desperate and I don't know where to start . I very
*simple* example in code would really help a lot.
Help!!
-Pam 8 2054
Hi Pam,
This sounds like a fairly simple ASP.NET page. Not sure why your spec
includes a "vb net application on a server pc" because the ASP.NET page can
do it all... that's what it was designed for.
Anyway, let us know if the ASP.NET 2.0 code below helps?
Ken
Microsoft MVP [ASP.NET]
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub btnSubmit_Click _
(ByVal sender As Object, ByVal e As System.EventArgs)
If txtQuery.Text <> "" Then
' Quick sample code to submit a SQL string
' and view the results in ASP.NET Gridview
' Ken Cox [MVP] - June 25/06
Dim strConnection As String
strConnection = "Data Source=.\SQLEXPRESS;" & _
"Initial Catalog=Northwind;Integrated Security=True"
Dim con As New Data.SqlClient.SqlConnection(strConnection)
' The following is probably not sufficient to protect you
' from a SQL injection attack but it's better than nothing
Dim cmdtext As String = SafeSqlLiteral(txtQuery.Text)
Dim cmd As New Data.SqlClient.SqlCommand(cmdtext, con)
Dim ds As New Data.DataSet
Dim da As New Data.SqlClient.SqlDataAdapter _
(cmdtext, strConnection)
da.Fill(ds)
GridView1.DataSource = ds
GridView1.DataBind()
End If
End Sub
Private Function SafeSqlLiteral(ByVal inputSQL As String) As String
Return inputSQL.Replace("'", "''")
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Textbox SQL query</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:textbox id="txtQuery" runat="server" width="470px"
text="SELECT companyname from customers"></asp:textbox><br />
<br />
<br />
<asp:button id="btnSubmit" runat="server"
onclick="btnSubmit_Click" text="Submit query" /><br />
<br />
<br />
<asp:gridview id="GridView1" runat="server">
</asp:gridview>
</div>
</form>
</body>
</html>
<pa***********@libero.it> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com... I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work.
This is what I need to accomplish:
---------------------- Given button and a TextBox on a web form when one presses the button on the web form on a client pc, the sql query which is contained in the text box is sent to a vb net application on a server pc. The win application sends the query to the database, collects the results, creates a web page showing some of these result and send the page back to the browser (for future queries).
1. client (Browser, IE) ----> WinApp on a Server pc ----> Database 2. Database --> WinApp on Server pc --> create NewAspPage --> client pc (Browser) ----------------------
I am kind of desperate and I don't know where to start . I very *simple* example in code would really help a lot.
Help!!
-Pam
Thank you Ken. This piece of the puzze I already have.
The problem is I want to send the request to a VB.NET program which is
running on the server because it must do some complicate processing
*before* doing the query and *after* doing the query. The response page
is not simply to fill a grid but the result of some processing that
must be done by the Vb.net application on the server. The VB.net
application also prepare a complex response page (with a lot of more
stuff, charts, pictures, photos, diagrams, etc) which I would like to
return to the browser.
What I have hard time to implement is passing data from the browser to
the VB.net application on the server, and, then, passing back the page
generated by the VB.net program back to the Browser. Just as I have
indicated in my schema. If you bypass the VB application you are not
answering to my original question. It's crucial the dialogue with the
server application.
Thanks for any help.
-Pam
Ken Cox [Microsoft MVP] ha scritto: Hi Pam,
This sounds like a fairly simple ASP.NET page. Not sure why your spec includes a "vb net application on a server pc" because the ASP.NET page can do it all... that's what it was designed for.
Anyway, let us know if the ASP.NET 2.0 code below helps?
Ken Microsoft MVP [ASP.NET]
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub btnSubmit_Click _ (ByVal sender As Object, ByVal e As System.EventArgs) If txtQuery.Text <> "" Then ' Quick sample code to submit a SQL string ' and view the results in ASP.NET Gridview ' Ken Cox [MVP] - June 25/06 Dim strConnection As String strConnection = "Data Source=.\SQLEXPRESS;" & _ "Initial Catalog=Northwind;Integrated Security=True" Dim con As New Data.SqlClient.SqlConnection(strConnection) ' The following is probably not sufficient to protect you ' from a SQL injection attack but it's better than nothing Dim cmdtext As String = SafeSqlLiteral(txtQuery.Text) Dim cmd As New Data.SqlClient.SqlCommand(cmdtext, con) Dim ds As New Data.DataSet Dim da As New Data.SqlClient.SqlDataAdapter _ (cmdtext, strConnection) da.Fill(ds) GridView1.DataSource = ds GridView1.DataBind() End If End Sub
Private Function SafeSqlLiteral(ByVal inputSQL As String) As String Return inputSQL.Replace("'", "''") End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Textbox SQL query</title> </head> <body> <form id="form1" runat="server"> <div> <asp:textbox id="txtQuery" runat="server" width="470px" text="SELECT companyname from customers"></asp:textbox><br /> <br /> <br /> <asp:button id="btnSubmit" runat="server" onclick="btnSubmit_Click" text="Submit query" /><br /> <br /> <br /> <asp:gridview id="GridView1" runat="server"> </asp:gridview> </div> </form> </body> </html>
<pa***********@libero.it> wrote in message news:11**********************@u72g2000cwu.googlegr oups.com...I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work.
This is what I need to accomplish:
---------------------- Given button and a TextBox on a web form when one presses the button on the web form on a client pc, the sql query which is contained in the text box is sent to a vb net application on a server pc. The win application sends the query to the database, collects the results, creates a web page showing some of these result and send the page back to the browser (for future queries).
1. client (Browser, IE) ----> WinApp on a Server pc ----> Database 2. Database --> WinApp on Server pc --> create NewAspPage --> client pc (Browser) ----------------------
I am kind of desperate and I don't know where to start . I very *simple* example in code would really help a lot.
Help!!
-Pam
You might look into
"web service"
or
"remoting"
I have a sample remoting service at: http://sholliday.spaces.msn.com/ 9/27/2005 entry. (You may have to "View
More" at the bottom to find it)
If you have biz logic in your winforms presentation layer, then I don't know
what youre going to do.
I've never heard of talking to a windows application from a web page. I'm
not saying it can't be done, but 10 years in the business, I've never heard
of it.
I understand I'm not answering your question exactly. That's because I
don't know what the answer is.
<pa***********@libero.it> wrote in message
news:11*********************@r2g2000cwb.googlegrou ps.com... Thank you Ken. This piece of the puzze I already have.
The problem is I want to send the request to a VB.NET program which is running on the server because it must do some complicate processing *before* doing the query and *after* doing the query. The response page is not simply to fill a grid but the result of some processing that must be done by the Vb.net application on the server. The VB.net application also prepare a complex response page (with a lot of more stuff, charts, pictures, photos, diagrams, etc) which I would like to return to the browser.
What I have hard time to implement is passing data from the browser to the VB.net application on the server, and, then, passing back the page generated by the VB.net program back to the Browser. Just as I have indicated in my schema. If you bypass the VB application you are not answering to my original question. It's crucial the dialogue with the server application.
Thanks for any help.
-Pam
Ken Cox [Microsoft MVP] ha scritto:
Hi Pam,
This sounds like a fairly simple ASP.NET page. Not sure why your spec includes a "vb net application on a server pc" because the ASP.NET page
can do it all... that's what it was designed for.
Anyway, let us know if the ASP.NET 2.0 code below helps?
Ken Microsoft MVP [ASP.NET]
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub btnSubmit_Click _ (ByVal sender As Object, ByVal e As System.EventArgs) If txtQuery.Text <> "" Then ' Quick sample code to submit a SQL string ' and view the results in ASP.NET Gridview ' Ken Cox [MVP] - June 25/06 Dim strConnection As String strConnection = "Data Source=.\SQLEXPRESS;" & _ "Initial Catalog=Northwind;Integrated Security=True" Dim con As New Data.SqlClient.SqlConnection(strConnection) ' The following is probably not sufficient to protect you ' from a SQL injection attack but it's better than nothing Dim cmdtext As String = SafeSqlLiteral(txtQuery.Text) Dim cmd As New Data.SqlClient.SqlCommand(cmdtext, con) Dim ds As New Data.DataSet Dim da As New Data.SqlClient.SqlDataAdapter _ (cmdtext, strConnection) da.Fill(ds) GridView1.DataSource = ds GridView1.DataBind() End If End Sub
Private Function SafeSqlLiteral(ByVal inputSQL As String) As String Return inputSQL.Replace("'", "''") End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Textbox SQL query</title> </head> <body> <form id="form1" runat="server"> <div> <asp:textbox id="txtQuery" runat="server" width="470px" text="SELECT companyname from customers"></asp:textbox><br /> <br /> <br /> <asp:button id="btnSubmit" runat="server" onclick="btnSubmit_Click" text="Submit query" /><br /> <br /> <br /> <asp:gridview id="GridView1" runat="server"> </asp:gridview> </div> </form> </body> </html>
<pa***********@libero.it> wrote in message news:11**********************@u72g2000cwu.googlegr oups.com...I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work.
This is what I need to accomplish:
---------------------- Given button and a TextBox on a web form when one presses the button
on the web form on a client pc, the sql query which is contained in the text box is sent to a vb net application on a server pc. The win application sends the query to the database, collects the results, creates a web page showing some of these result and send the page back to the browser (for future queries).
1. client (Browser, IE) ----> WinApp on a Server pc ----> Database 2. Database --> WinApp on Server pc --> create NewAspPage --> client pc (Browser) ----------------------
I am kind of desperate and I don't know where to start . I very *simple* example in code would really help a lot.
Help!!
-Pam
Thanks Sloan
you mean "Leveraging Dot Net Remoting To Keep Your "Secret Code" Safe",
right.
Actually that's a nice repository of good information.
I am a little worried by your answer, especially after reading the
material on the blog. My scheme would seem quite common and it's hard
to believe that .net does not provide ways to deal with it.
After all, I just want to talk - using a browser - with my application
running on a server. Is it possible that .net has not envisioned this
possibility? Or am I missing something important?
-Pam
sloan ha scritto: You might look into
"web service" or "remoting"
I have a sample remoting service at: http://sholliday.spaces.msn.com/ 9/27/2005 entry. (You may have to "View More" at the bottom to find it)
If you have biz logic in your winforms presentation layer, then I don't know what youre going to do. I've never heard of talking to a windows application from a web page. I'm not saying it can't be done, but 10 years in the business, I've never heard of it.
I understand I'm not answering your question exactly. That's because I don't know what the answer is.
<pa***********@libero.it> wrote in message news:11*********************@r2g2000cwb.googlegrou ps.com... Thank you Ken. This piece of the puzze I already have.
The problem is I want to send the request to a VB.NET program which is running on the server because it must do some complicate processing *before* doing the query and *after* doing the query. The response page is not simply to fill a grid but the result of some processing that must be done by the Vb.net application on the server. The VB.net application also prepare a complex response page (with a lot of more stuff, charts, pictures, photos, diagrams, etc) which I would like to return to the browser.
What I have hard time to implement is passing data from the browser to the VB.net application on the server, and, then, passing back the page generated by the VB.net program back to the Browser. Just as I have indicated in my schema. If you bypass the VB application you are not answering to my original question. It's crucial the dialogue with the server application.
Thanks for any help.
-Pam
Ken Cox [Microsoft MVP] ha scritto:
Hi Pam,
This sounds like a fairly simple ASP.NET page. Not sure why your spec includes a "vb net application on a server pc" because the ASP.NET page can do it all... that's what it was designed for.
Anyway, let us know if the ASP.NET 2.0 code below helps?
Ken Microsoft MVP [ASP.NET]
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub btnSubmit_Click _ (ByVal sender As Object, ByVal e As System.EventArgs) If txtQuery.Text <> "" Then ' Quick sample code to submit a SQL string ' and view the results in ASP.NET Gridview ' Ken Cox [MVP] - June 25/06 Dim strConnection As String strConnection = "Data Source=.\SQLEXPRESS;" & _ "Initial Catalog=Northwind;Integrated Security=True" Dim con As New Data.SqlClient.SqlConnection(strConnection) ' The following is probably not sufficient to protect you ' from a SQL injection attack but it's better than nothing Dim cmdtext As String = SafeSqlLiteral(txtQuery.Text) Dim cmd As New Data.SqlClient.SqlCommand(cmdtext, con) Dim ds As New Data.DataSet Dim da As New Data.SqlClient.SqlDataAdapter _ (cmdtext, strConnection) da.Fill(ds) GridView1.DataSource = ds GridView1.DataBind() End If End Sub
Private Function SafeSqlLiteral(ByVal inputSQL As String) As String Return inputSQL.Replace("'", "''") End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Textbox SQL query</title> </head> <body> <form id="form1" runat="server"> <div> <asp:textbox id="txtQuery" runat="server" width="470px" text="SELECT companyname from customers"></asp:textbox><br /> <br /> <br /> <asp:button id="btnSubmit" runat="server" onclick="btnSubmit_Click" text="Submit query" /><br /> <br /> <br /> <asp:gridview id="GridView1" runat="server"> </asp:gridview> </div> </form> </body> </html>
<pa***********@libero.it> wrote in message news:11**********************@u72g2000cwu.googlegr oups.com... >I am beginning aspNet, I know well win apps. > Need a simple and schematic code example to start work. > > This is what I need to accomplish: > > ---------------------- > Given button and a TextBox on a web form when one presses the button on > the web form on a client pc, the sql query which is contained in the > text box is sent to a vb net application on a server pc. The win > application sends the query to the database, collects the results, > creates a web page showing some of these result and send the page back > to the browser (for future queries). > > 1. client (Browser, IE) ----> WinApp on a Server pc ----> Database > 2. Database --> WinApp on Server pc --> create NewAspPage --> client > pc (Browser) > ---------------------- > > I am kind of desperate and I don't know where to start . I very > *simple* example in code would really help a lot. > > Help!! > > -Pam >
Hi Pam,
It sounds like you want to create your own custom HttpHandler. It can get
the posted query from System.Web.HttpContext and pass that along to get the
data. Once you've built the HTML code, you ship it back out with
HttpResponse.
If you do a search on IHttpHandler and HttpContext you'll get more info.
Here's a starter that generates a 'Hello World' HTML page. http://msdn.microsoft.com/library/de...processing.asp
Can't help more than that because I haven't used that capability. It seems
to me there must be easier ways such as user controls or Web parts to do
what you need.
Ken
Microsoft MVP [ASP.NET]
<pa***********@libero.it> wrote in message
news:11*********************@r2g2000cwb.googlegrou ps.com... Thank you Ken. This piece of the puzze I already have.
The problem is I want to send the request to a VB.NET program which is running on the server because it must do some complicate processing *before* doing the query and *after* doing the query. The response page is not simply to fill a grid but the result of some processing that must be done by the Vb.net application on the server. The VB.net application also prepare a complex response page (with a lot of more stuff, charts, pictures, photos, diagrams, etc) which I would like to return to the browser.
What I have hard time to implement is passing data from the browser to the VB.net application on the server, and, then, passing back the page generated by the VB.net program back to the Browser. Just as I have indicated in my schema. If you bypass the VB application you are not answering to my original question. It's crucial the dialogue with the server application.
Thanks for any help.
-Pam
Ken Cox [Microsoft MVP] ha scritto:
Hi Pam,
This sounds like a fairly simple ASP.NET page. Not sure why your spec includes a "vb net application on a server pc" because the ASP.NET page can do it all... that's what it was designed for.
Anyway, let us know if the ASP.NET 2.0 code below helps?
Ken Microsoft MVP [ASP.NET]
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub btnSubmit_Click _ (ByVal sender As Object, ByVal e As System.EventArgs) If txtQuery.Text <> "" Then ' Quick sample code to submit a SQL string ' and view the results in ASP.NET Gridview ' Ken Cox [MVP] - June 25/06 Dim strConnection As String strConnection = "Data Source=.\SQLEXPRESS;" & _ "Initial Catalog=Northwind;Integrated Security=True" Dim con As New Data.SqlClient.SqlConnection(strConnection) ' The following is probably not sufficient to protect you ' from a SQL injection attack but it's better than nothing Dim cmdtext As String = SafeSqlLiteral(txtQuery.Text) Dim cmd As New Data.SqlClient.SqlCommand(cmdtext, con) Dim ds As New Data.DataSet Dim da As New Data.SqlClient.SqlDataAdapter _ (cmdtext, strConnection) da.Fill(ds) GridView1.DataSource = ds GridView1.DataBind() End If End Sub
Private Function SafeSqlLiteral(ByVal inputSQL As String) As String Return inputSQL.Replace("'", "''") End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Textbox SQL query</title> </head> <body> <form id="form1" runat="server"> <div> <asp:textbox id="txtQuery" runat="server" width="470px" text="SELECT companyname from customers"></asp:textbox><br /> <br /> <br /> <asp:button id="btnSubmit" runat="server" onclick="btnSubmit_Click" text="Submit query" /><br /> <br /> <br /> <asp:gridview id="GridView1" runat="server"> </asp:gridview> </div> </form> </body> </html>
<pa***********@libero.it> wrote in message news:11**********************@u72g2000cwu.googlegr oups.com... >I am beginning aspNet, I know well win apps. > Need a simple and schematic code example to start work. > > This is what I need to accomplish: > > ---------------------- > Given button and a TextBox on a web form when one presses the button on > the web form on a client pc, the sql query which is contained in the > text box is sent to a vb net application on a server pc. The win > application sends the query to the database, collects the results, > creates a web page showing some of these result and send the page back > to the browser (for future queries). > > 1. client (Browser, IE) ----> WinApp on a Server pc ----> Database > 2. Database --> WinApp on Server pc --> create NewAspPage --> client > pc (Browser) > ---------------------- > > I am kind of desperate and I don't know where to start . I very > *simple* example in code would really help a lot. > > Help!! > > -Pam >
Hi Ken
actually there is a simple hello world example which *seems* to be in
right direction. The rest of the documentation is quite concise and it
seems there is a long struggle to do.
I am not clear if the Process Request is routed by IIS to the
IHttpHandler (which I might enclose in my server application) or the
talk is directly between the Browser and the IHttpHandler (?)
I see not many people out there are using this stuff, but, to me, it
seems quite useful to be able to talk to an application through a
browser. If someone has some code or pointers to show how to use these
handlers it would be great.
If there other suggestions I will be listening here! Thank you
-pam
example from documentation:
----------------------------------------------------------
Imports System.Web
Public Class HelloWorldHandler
Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As System.Web.HttpContext)
Implements System.Web.IHttpHandler.ProcessRequest
Dim request As HttpRequest = context.Request
Dim response As HttpResponse = context.Response
' A file named ending in .MyHello need not exist. This handler
' executes whenever a file ending in .MyHello is requested.
response.Write("<html>")
response.Write("<body>")
response.Write("<h1> Hello from Synchronous custom handler.
</h1>")
response.Write("</body>")
response.Write("</html>")
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements
System.Web.IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
Ken Cox [Microsoft MVP] ha scritto: Hi Pam,
It sounds like you want to create your own custom HttpHandler. It can get the posted query from System.Web.HttpContext and pass that along to get the data. Once you've built the HTML code, you ship it back out with HttpResponse.
If you do a search on IHttpHandler and HttpContext you'll get more info. Here's a starter that generates a 'Hello World' HTML page.
http://msdn.microsoft.com/library/de...processing.asp
Can't help more than that because I haven't used that capability. It seems to me there must be easier ways such as user controls or Web parts to do what you need.
Ken Microsoft MVP [ASP.NET]
<pa***********@libero.it> wrote in message news:11*********************@r2g2000cwb.googlegrou ps.com... Thank you Ken. This piece of the puzze I already have.
The problem is I want to send the request to a VB.NET program which is running on the server because it must do some complicate processing *before* doing the query and *after* doing the query. The response page is not simply to fill a grid but the result of some processing that must be done by the Vb.net application on the server. The VB.net application also prepare a complex response page (with a lot of more stuff, charts, pictures, photos, diagrams, etc) which I would like to return to the browser.
What I have hard time to implement is passing data from the browser to the VB.net application on the server, and, then, passing back the page generated by the VB.net program back to the Browser. Just as I have indicated in my schema. If you bypass the VB application you are not answering to my original question. It's crucial the dialogue with the server application.
Thanks for any help.
-Pam
Ken Cox [Microsoft MVP] ha scritto:
Hi Pam,
This sounds like a fairly simple ASP.NET page. Not sure why your spec includes a "vb net application on a server pc" because the ASP.NET page can do it all... that's what it was designed for.
Anyway, let us know if the ASP.NET 2.0 code below helps?
Ken Microsoft MVP [ASP.NET]
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub btnSubmit_Click _ (ByVal sender As Object, ByVal e As System.EventArgs) If txtQuery.Text <> "" Then ' Quick sample code to submit a SQL string ' and view the results in ASP.NET Gridview ' Ken Cox [MVP] - June 25/06 Dim strConnection As String strConnection = "Data Source=.\SQLEXPRESS;" & _ "Initial Catalog=Northwind;Integrated Security=True" Dim con As New Data.SqlClient.SqlConnection(strConnection) ' The following is probably not sufficient to protect you ' from a SQL injection attack but it's better than nothing Dim cmdtext As String = SafeSqlLiteral(txtQuery.Text) Dim cmd As New Data.SqlClient.SqlCommand(cmdtext, con) Dim ds As New Data.DataSet Dim da As New Data.SqlClient.SqlDataAdapter _ (cmdtext, strConnection) da.Fill(ds) GridView1.DataSource = ds GridView1.DataBind() End If End Sub
Private Function SafeSqlLiteral(ByVal inputSQL As String) As String Return inputSQL.Replace("'", "''") End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Textbox SQL query</title> </head> <body> <form id="form1" runat="server"> <div> <asp:textbox id="txtQuery" runat="server" width="470px" text="SELECT companyname from customers"></asp:textbox><br /> <br /> <br /> <asp:button id="btnSubmit" runat="server" onclick="btnSubmit_Click" text="Submit query" /><br /> <br /> <br /> <asp:gridview id="GridView1" runat="server"> </asp:gridview> </div> </form> </body> </html>
<pa***********@libero.it> wrote in message news:11**********************@u72g2000cwu.googlegr oups.com... >I am beginning aspNet, I know well win apps. > Need a simple and schematic code example to start work. > > This is what I need to accomplish: > > ---------------------- > Given button and a TextBox on a web form when one presses the button on > the web form on a client pc, the sql query which is contained in the > text box is sent to a vb net application on a server pc. The win > application sends the query to the database, collects the results, > creates a web page showing some of these result and send the page back > to the browser (for future queries). > > 1. client (Browser, IE) ----> WinApp on a Server pc ----> Database > 2. Database --> WinApp on Server pc --> create NewAspPage --> client > pc (Browser) > ---------------------- > > I am kind of desperate and I don't know where to start . I very > *simple* example in code would really help a lot. > > Help!! > > -Pam >
Pamela,
Actually, the idea would be to create a class that the browser based
program would call to do the processing. This would contain all of the
business logic that you are saying is in the VB application. It is
like creating a DLL for use by multiple applications and placing it on
the server.
Robert pa***********@libero.it wrote: Thank you Ken. This piece of the puzze I already have.
The problem is I want to send the request to a VB.NET program which is running on the server because it must do some complicate processing *before* doing the query and *after* doing the query. The response page is not simply to fill a grid but the result of some processing that must be done by the Vb.net application on the server. The VB.net application also prepare a complex response page (with a lot of more stuff, charts, pictures, photos, diagrams, etc) which I would like to return to the browser.
What I have hard time to implement is passing data from the browser to the VB.net application on the server, and, then, passing back the page generated by the VB.net program back to the Browser. Just as I have indicated in my schema. If you bypass the VB application you are not answering to my original question. It's crucial the dialogue with the server application.
Thanks for any help.
-Pam
Ken Cox [Microsoft MVP] ha scritto:
Hi Pam,
This sounds like a fairly simple ASP.NET page. Not sure why your spec includes a "vb net application on a server pc" because the ASP.NET page can do it all... that's what it was designed for.
Anyway, let us know if the ASP.NET 2.0 code below helps?
Ken Microsoft MVP [ASP.NET]
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub btnSubmit_Click _ (ByVal sender As Object, ByVal e As System.EventArgs) If txtQuery.Text <> "" Then ' Quick sample code to submit a SQL string ' and view the results in ASP.NET Gridview ' Ken Cox [MVP] - June 25/06 Dim strConnection As String strConnection = "Data Source=.\SQLEXPRESS;" & _ "Initial Catalog=Northwind;Integrated Security=True" Dim con As New Data.SqlClient.SqlConnection(strConnection) ' The following is probably not sufficient to protect you ' from a SQL injection attack but it's better than nothing Dim cmdtext As String = SafeSqlLiteral(txtQuery.Text) Dim cmd As New Data.SqlClient.SqlCommand(cmdtext, con) Dim ds As New Data.DataSet Dim da As New Data.SqlClient.SqlDataAdapter _ (cmdtext, strConnection) da.Fill(ds) GridView1.DataSource = ds GridView1.DataBind() End If End Sub
Private Function SafeSqlLiteral(ByVal inputSQL As String) As String Return inputSQL.Replace("'", "''") End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Textbox SQL query</title> </head> <body> <form id="form1" runat="server"> <div> <asp:textbox id="txtQuery" runat="server" width="470px" text="SELECT companyname from customers"></asp:textbox><br /> <br /> <br /> <asp:button id="btnSubmit" runat="server" onclick="btnSubmit_Click" text="Submit query" /><br /> <br /> <br /> <asp:gridview id="GridView1" runat="server"> </asp:gridview> </div> </form> </body> </html>
<pa***********@libero.it> wrote in message news:11**********************@u72g2000cwu.googlegr oups.com...I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work.
This is what I need to accomplish:
---------------------- Given button and a TextBox on a web form when one presses the button on the web form on a client pc, the sql query which is contained in the text box is sent to a vb net application on a server pc. The win application sends the query to the database, collects the results, creates a web page showing some of these result and send the page back to the browser (for future queries).
1. client (Browser, IE) ----> WinApp on a Server pc ----> Database 2. Database --> WinApp on Server pc --> create NewAspPage --> client pc (Browser) ----------------------
I am kind of desperate and I don't know where to start . I very *simple* example in code would really help a lot.
Help!!
-Pam
have you got my email?
raibeart ha scritto: Pamela,
Actually, the idea would be to create a class that the browser based program would call to do the processing. This would contain all of the business logic that you are saying is in the VB application. It is like creating a DLL for use by multiple applications and placing it on the server.
Robert
pa***********@libero.it wrote: Thank you Ken. This piece of the puzze I already have.
The problem is I want to send the request to a VB.NET program which is running on the server because it must do some complicate processing *before* doing the query and *after* doing the query. The response page is not simply to fill a grid but the result of some processing that must be done by the Vb.net application on the server. The VB.net application also prepare a complex response page (with a lot of more stuff, charts, pictures, photos, diagrams, etc) which I would like to return to the browser.
What I have hard time to implement is passing data from the browser to the VB.net application on the server, and, then, passing back the page generated by the VB.net program back to the Browser. Just as I have indicated in my schema. If you bypass the VB application you are not answering to my original question. It's crucial the dialogue with the server application.
Thanks for any help.
-Pam
Ken Cox [Microsoft MVP] ha scritto:
Hi Pam,
This sounds like a fairly simple ASP.NET page. Not sure why your spec includes a "vb net application on a server pc" because the ASP.NET page can do it all... that's what it was designed for.
Anyway, let us know if the ASP.NET 2.0 code below helps?
Ken Microsoft MVP [ASP.NET]
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub btnSubmit_Click _ (ByVal sender As Object, ByVal e As System.EventArgs) If txtQuery.Text <> "" Then ' Quick sample code to submit a SQL string ' and view the results in ASP.NET Gridview ' Ken Cox [MVP] - June 25/06 Dim strConnection As String strConnection = "Data Source=.\SQLEXPRESS;" & _ "Initial Catalog=Northwind;Integrated Security=True" Dim con As New Data.SqlClient.SqlConnection(strConnection) ' The following is probably not sufficient to protect you ' from a SQL injection attack but it's better than nothing Dim cmdtext As String = SafeSqlLiteral(txtQuery.Text) Dim cmd As New Data.SqlClient.SqlCommand(cmdtext, con) Dim ds As New Data.DataSet Dim da As New Data.SqlClient.SqlDataAdapter _ (cmdtext, strConnection) da.Fill(ds) GridView1.DataSource = ds GridView1.DataBind() End If End Sub
Private Function SafeSqlLiteral(ByVal inputSQL As String) As String Return inputSQL.Replace("'", "''") End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Textbox SQL query</title> </head> <body> <form id="form1" runat="server"> <div> <asp:textbox id="txtQuery" runat="server" width="470px" text="SELECT companyname from customers"></asp:textbox><br /> <br /> <br /> <asp:button id="btnSubmit" runat="server" onclick="btnSubmit_Click" text="Submit query" /><br /> <br /> <br /> <asp:gridview id="GridView1" runat="server"> </asp:gridview> </div> </form> </body> </html>
<pa***********@libero.it> wrote in message news:11**********************@u72g2000cwu.googlegr oups.com... >I am beginning aspNet, I know well win apps. > Need a simple and schematic code example to start work. > > This is what I need to accomplish: > > ---------------------- > Given button and a TextBox on a web form when one presses the button on > the web form on a client pc, the sql query which is contained in the > text box is sent to a vb net application on a server pc. The win > application sends the query to the database, collects the results, > creates a web page showing some of these result and send the page back > to the browser (for future queries). > > 1. client (Browser, IE) ----> WinApp on a Server pc ----> Database > 2. Database --> WinApp on Server pc --> create NewAspPage --> client > pc (Browser) > ---------------------- > > I am kind of desperate and I don't know where to start . I very > *simple* example in code would really help a lot. > > Help!! > > -Pam > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rodney King |
last post by:
Hi,
I have developed an ASP page which dynamically displays a list of
checkbox options based on a SQL statement. Here is my code:
<div style="OVERFLOW:auto; Height: 150px">
<table>
<%
dim...
|
by: Mike Kamermans |
last post by:
I hope someone can help me, because what I'm going through at the moment
trying to edit XML documents is enough to make me want to never edit XML
again.
I'm looking for an XML editor that has a...
|
by: robert |
last post by:
I've made a gallery site for an artist and it works well -- the gallery
page has a central large image which is swapped when thumbnail images
are clicked. I'm using Dreamweaver's "SwapImage"...
|
by: EkteGjetost |
last post by:
This is definitely not the smart thing to do as far as my learning goes,
but desperate situations call for desperate measures.
The final lab for my introduction to C programming class is due...
|
by: Joey Liang via DotNetMonster.com |
last post by:
Hi all,
I have a drop down list which store all the different brands of
product.When i selected the particular brand from the drop down list, it
will display all the products with the selected...
|
by: Gordon |
last post by:
Hello again,
Sorry to repost this request, but I'm under a bit of pressure to find a
quick solution.
All I basically want is an automatically updating link (OLE, not DDE)
between a control in...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |