Re: Desperately need help to setup with asp net !!
- From: "Ken Cox [Microsoft MVP]" <BANSPAMkjopc@xxxxxxxxxxxxxxxxx>
- Date: Sun, 25 Jun 2006 13:34:34 -0400
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>
<pamelafluente@xxxxxxxxx> wrote in message
news:1151249546.731638.175320@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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
.
- Follow-Ups:
- Re: Desperately need help to setup with asp net !!
- From: pamelafluente
- Re: Desperately need help to setup with asp net !!
- References:
- Desperately need help to setup with asp net !!
- From: pamelafluente
- Desperately need help to setup with asp net !!
- Prev by Date: Converting datareader value
- Next by Date: Re: Dreamweaver to ASP.Net 2003
- Previous by thread: Desperately need help to setup with asp net !!
- Next by thread: Re: Desperately need help to setup with asp net !!
- Index(es):