本文介绍了在SQL Server数据库中插入数据的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在xslt的帮助下使用存储过程将数据插入数据库,但是数据不在数据库中,所以请帮助我哪里出错了. 我的存储过程是这个
I want to insert the data into data base using store procedure with the help of xslt, but data is not going in the data base, so please help me where am i doing fault. my stored procedure is this-
USE [DTITSWEB] GO /****** Object: StoredProcedure [dbo].[webinsert] Script Date: 08/10/2011 17:07:18 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= ALTER PROCEDURE [dbo].[webinsert] ( @v_strUsername NVARCHAR(20), @v_strPassword NVARCHAR(50)) AS BEGIN DECLARE @intAutoId INT SELECT @intAutoId = MAX(AutoId)FROM AdminLogin IF @intAutoId IS NULL SET @intAutoId = 1 ELSE SET @intAutoId = @intAutoId + 1 INSERT INTO AdminLogin ( AutoId, UserName, Password ) VALUES ( @intAutoId, @v_strUsername , @v_strPassword ) END我的地图是这个
and my maping is this-
string strSPName; bool blnSuccess; try { strSPName = "webinsert"; SqlParameter[] arProcParams = { new SqlParameter("@v_strUsername", vstrUsername), new SqlParameter("@v_strPassword", vstrPassword) }; blnSuccess = oDU.ExecuteStoredProc(strSPName, arProcParams); if (!blnSuccess) throw new Exception("There were some problem with Add."); return true; } catch { throw; }推荐答案
为什么要手动创建ID?只需将ID字段设置为自动递增,然后在您插入新行时就会为您处理. WHY are you manually creating the ID? Just set the ID field to be auto-increment, and it will take care of this for you when you insert a new row.
更多推荐
在SQL Server数据库中插入数据的问题
发布评论