[Solved] accept post data in asp and insert into sql server


It’s mostly VB, just switch to it

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim myConn As SqlConnection = New SqlConnection("Integrated Security=false;Data Source=.;Initial Catalog=DOMAIN_NAME;UserID=abc;Password=123")
        myConn.Open()
        Dim sqlstring As String = " INSERT INTO sean.local (etype, latitude, longtitude, phone) VALUES ('" + Request.Form("type") + "','" + Request.Form("latitude") + "','" + Request.Form("longtitude") + "','" + Request.Form("phone") + "')"
        Dim cmd As SqlCommand = New SqlCommand(sqlstring, myConn)
        cmd.ExecuteNonQuery()
        myConn.Close()
        Response.Redirect(Request.RawUrl, True)
        Response.Write("1 record added")
    End Sub
</script>

If you need it in C#, run it through this: http://wiki.sharpdevelop.net/Code%20Converter.ashx

1

solved accept post data in asp and insert into sql server