문제

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