Desperately need help to setup with asp net !!

P

pamelafluente

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
 
K

Ken Cox [Microsoft MVP]

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>
&nbsp;</div>
</form>
</body>
</html>
 
P

pamelafluente

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>
&nbsp;</div>
</form>
</body>
</html>

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
 
S

sloan

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.




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>
&nbsp;</div>
</form>
</body>
</html>

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
 
P

pamelafluente

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.




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>
&nbsp;</div>
</form>
</body>
</html>

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
 
K

Ken Cox [Microsoft MVP]

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/d...cpguide/html/cpconaspnetrequestprocessing.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]


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>
&nbsp;</div>
</form>
</body>
</html>

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
 
P

pamelafluente

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/d...cpguide/html/cpconaspnetrequestprocessing.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]


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>
&nbsp;</div>
</form>
</body>
</html>

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
 
R

raibeart

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

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>
&nbsp;</div>
</form>
</body>
</html>

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
 
P

pamelafluente

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

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>
&nbsp;</div>
</form>
</body>
</html>

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
 

Ask a Question

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

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

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top