English 中文(简体)
ASP.NET/VB.NET: 生成插入命令
原标题:ASP.NET / VB.NET : Generate Insert Command

我所有的形式变量都在我的代码后面, 它们都是用“ 请求. 表格” 检索的。

据我所知,..如果我使用 SQLData 源来做这件事,我不得不使用 ASP.NET 控制器(我不想用) 。

INSERT INTO Orders(FirstName, LastName, Email, PhoneNumber, Address, City, State, ZipCode, PaymentMethod, PromoCode, OrderStatus, Tracking, PPEmail, SubmissionDate) VALUES (@FirstName, @LastName, @Email, @Phone, @Address, @City, @State, 11111, @PaymentMethod ,  0 ,  New Order - Pending ,  0 , @PPEMAIL, @Date)

代码后面

    Dim fPrice As String = CType(Session.Item("Qprice"), String)
    Dim DeviceMake As String = CType(Session.Item("Make"), String)
    Dim PaymentMethod As String = Request.Form("Payment Type")
    Dim DeviceModel As String = CType(Session.Item("Model"), String)
    Dim DeviceCondition As String = CType(Session.Item("Condition"), String)
    Dim SubmissionDate As String = Date.Now.ToString
    Dim FirstName = Request.Form("First")
    Dim LastName = Request.Form("Last")
    Dim City = Request.Form("City")
    Dim Phone = Request.Form("Phone")
    Dim Address = Request.Form("Address")
    Dim State = Request.Form("State")
    Dim Zip = Request.Form("Zip")
    Dim Email = Request.Form("EMail")

是否有一种方法可以让我的变量连接到 SQLDatasource 生成的插图中, 无需手动编码参数?

最佳回答
问题回答

您最好强制附加参数。 当您正在从 Form and Assession( ick) 获得您的值时, SQL 参数化将会为您提供一定程度的保护 。

您可能想要探索代码生成( A-la < a href=""http://msdn.microsoft.com/ en- us/library/bb1264.45.aspx" rel="nofollow" >T4





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签