I'm using ASP.NET forms to build some quite lengthy questionnaires. I'm creating each page using a FormView control with an attached SQL dataSource. The select query is easy enough- Visual Studio generates:

 (select * from table)

but for the update query, Visual Studio gives me:

UPDATE table SET field1=,field2=... etc.

and I need:

UPDATE table SET field1=@field1,field2=@field2... etc.

At the moment, I'm copying each field name, pasting it after the = and adding an '@', but this gets really tedious.

Is there a way of automatically adding a parameter for each field?

有帮助吗?

解决方案

OK, found the solution now.

  1. Click 'configure DataSource' on the SmartTag
  2. On the 'Configure the Select statement' page of the wizard, choose 'Specify tables from a table or view
  3. Click the 'Advanced' button
  4. Select 'Generate Delete, Insert and update Queries'

NB, for this to work, your select statement must contain the Primary key of the table.

其他提示

Using Third party Tool SSMS tool for Autogenerated StoredProcedures in MSSQLServer It's Generated Insert,Update,Select,Delete Query with Parameter Use in DB

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top