insert into company (com_name,erea_id) values ('"+txtcor_name.text.trim()+"','"+ddlerea.selectedvalue+"')com_id自增

解决方案 »

  1.   

    写个简单的存储过程,仅供参考create proc insert_company_info
    (
    @txtCompanyName varchar(50),
    @txtAreaName char(10)
    )
    as
    declare @intAreaID int
    set @intAreaID=(select area_id from area where area_name=@txtCompanyName) --不过输入的不一定能在数据库中查询到相应的数据,输入内容要规范化
    --加入查询不到就是null,建议做个判断,为null时,给个数字
    insert into company(com_name,area_id) values(@txtCompanyName,@intAreaID)
    go
      

  2.   

    Click the link to solve your problem.Good luck!