在SQL Server数据库中插入数据的问题

编程入门 行业动态 更新时间:2024-10-27 10:24:38
本文介绍了在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数据库中插入数据的问题

本文发布于:2023-10-12 17:38:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485408.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库中   数据   SQL   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!