473,804 Members | 3,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problems inserting into sql using SqlHelper.Execu teScalar

I'm having problems inserting into Sql 2000 using SqlHelper.Execu teScalar.
When it inserts, it only takes the first character from the string?? Any help would be appreciated. Here is the code and the stored procedure I'm using.

Dim newRowId As Integer
newRowId = Convert.ToInt32 (SqlHelper.Exec uteScalar(Confi gurationSetting s.AppSettings(" ConnectionStrin g"), "ProcContactsIn sert", 1234, "hparameter 2", "parameter2 ", "tparamer2" , "pareter2", "ypameter2" , "parTitle", "parater2", 1, 0, 1, 0, "parameer2" ))

---------------------

CREATE PROCEDURE ProcContactsIns ert
@CustID int,
@Cont1FirstName nvarchar,
@Cont1LastName nvarchar,
@Cont1Phone nvarchar,
@Cont1PhoneExt nvarchar,
@Cont1Fax nvarchar,
@Title nvarchar,
@Email nvarchar,
@Presort bit,
@PresortMeter bit,
@LetterShop bit,
@Printing bit,
@CellPhone nvarchar
AS
INSERT INTO Contacts (CustID, Cont1FirstName, Cont1LastName, Cont1Phone, Cont1PhoneExt, Cont1Fax, Title, Email, Presort, PresortMeter, LetterShop, Printing, CellPhone)
VALUES (@CustID, @Cont1FirstName , @Cont1LastName, @Cont1Phone, @Cont1PhoneExt, @Cont1Fax, @Title, @Email, @Presort, @PresortMeter, @LetterShop, @Printing, @CellPhone)
SELECT CAST(scope_iden tity() AS INTEGER)
RETURN
GO

------
It returns the correct id number but the varchar fields are only recieving the first character of the values.

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>BV3JhSpJ+0W MFtGSqpPgGg==</Id>
Nov 18 '05 #1
1 3069
please specify the length of varchars in your stored procedure

some thing like (the length of varchar should be less than or equal to
length of the column) i usually prefer equal - (dont see a reason why not)

CREATE PROCEDURE ProcContactsIns ert
@CustID int,
@Cont1FirstName nvarchar(25),
@Cont1LastName nvarchar(25),
@Cont1Phone nvarchar(10),
@Cont1PhoneExt nvarchar(4),
@Cont1Fax nvarchar(10),
@Title nvarchar(3),
@Email nvarchar(100),
@Presort bit,
@PresortMeter bit,
@LetterShop bit,
@Printing bit,
@CellPhone nvarchar(10)
AS
INSERT INTO Contacts (CustID, Cont1FirstName, Cont1LastName, Cont1Phone,
Cont1PhoneExt, Cont1Fax, Title, Email, Presort, PresortMeter, LetterShop,
Printing, CellPhone)
VALUES (@CustID, @Cont1FirstName , @Cont1LastName, @Cont1Phone,
@Cont1PhoneExt, @Cont1Fax, @Title, @Email, @Presort, @PresortMeter,
@LetterShop, @Printing, @CellPhone)
SELECT CAST(scope_iden tity() AS INTEGER)
RETURN
GO

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Chad Dittmer via .NET 247" <an*******@dotn et247.com> wrote in message
news:e#******** ******@tk2msftn gp13.phx.gbl...
I'm having problems inserting into Sql 2000 using SqlHelper.Execu teScalar.
When it inserts, it only takes the first character from the string?? Any help would be appreciated. Here is the code and the stored procedure I'm
using.
Dim newRowId As Integer
newRowId = Convert.ToInt32 (SqlHelper.Exec uteScalar(Confi gurationSetting s.AppSettings(" C
onnectionString "), "ProcContactsIn sert", 1234, "hparameter 2", "parameter2 ",
"tparamer2" , "pareter2", "ypameter2" , "parTitle", "parater2", 1, 0, 1, 0,
"parameer2" ))
---------------------

CREATE PROCEDURE ProcContactsIns ert
@CustID int,
@Cont1FirstName nvarchar,
@Cont1LastName nvarchar,
@Cont1Phone nvarchar,
@Cont1PhoneExt nvarchar,
@Cont1Fax nvarchar,
@Title nvarchar,
@Email nvarchar,
@Presort bit,
@PresortMeter bit,
@LetterShop bit,
@Printing bit,
@CellPhone nvarchar
AS
INSERT INTO Contacts (CustID, Cont1FirstName, Cont1LastName, Cont1Phone, Cont1PhoneExt, Cont1Fax, Title, Email, Presort, PresortMeter, LetterShop,
Printing, CellPhone) VALUES (@CustID, @Cont1FirstName , @Cont1LastName, @Cont1Phone, @Cont1PhoneExt, @Cont1Fax, @Title, @Email, @Presort, @PresortMeter,
@LetterShop, @Printing, @CellPhone) SELECT CAST(scope_iden tity() AS INTEGER)
RETURN
GO

------
It returns the correct id number but the varchar fields are only recieving the first character of the values.
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>BV3JhSpJ+0W MFtGSqpPgGg==</Id>

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6707
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
3
1800
by: Eric Lilja | last post by:
Hello, I'm creating a small utility for an online game. It involves parsing a text file of "tradesskill recipes" and inserting these recipes in a gui tree widget (similar to gui file browsers if you know what I mean). Here's an example of a recipe as it appears in the text file: * Cashew Pie (lvl 39, 5h 3 min, + max power) - Candied Cashew (level 30) -- Cashew -- Refined Honey (level 30) --- Raw Honey
0
1651
by: Rajesh Kumar | last post by:
Hi Gregory Thanks for your answer. I did not see any attached file so I copied your text into a text file and named it compiler.bat Checked the wrapped lines and runned the file. It said Dataset, Datareader and some other things are not defined. So I entered the : Imports Microsoft.ApplicationBlocks.Data Imports system Imports system.data Imports System.Data.SqlClient
6
3505
by: Max | last post by:
Anyone know why I'm always getting 0 returned? My stored procedure returns -1. Dim iErrorCode As Int32 iErrorCode = Convert.ToInt32(SqlHelper.ExecuteScalar(AppVars.strConn, _ "gpUpdateMember", _ Convert.ToInt32(lblMember_id.Text), _ -snip- -Max
7
12021
by: Neven Klofutar | last post by:
Hi, I have a problem with SqlHelper.ExecuteScalar ... When I try to execute SqlHelper.ExecuteScalar I get this message: "System.InvalidCastException: Object must implement IConvertible.". Help ... Thanx, Neven
0
1242
by: hansiman | last post by:
How do I read a stored proc return value ( return(@return_value) ) using MS Data Access Application Block. Normally I use: Dim conn As SqlConnection = New SqlConnection("connectionstring") Dim cmd As SqlCommand = New SqlCommand cmd.Connection = conn cmd.CommandText = "NameOfStoredProc"
0
1440
by: Mike | last post by:
Hi, I am trying to insert parameters into a stored procedure using DAAB (see code at the bottom of this post). I am getting the following error: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details:...
7
7546
by: RJN | last post by:
Hi I want to get the rerurn value from a stored procedure My stored proc looks like this create proc test ..... if.. return 1
2
1386
by: Paul | last post by:
I'm sure this isn't a difficult question, but I've been struggling trying to insert the current date into a sql server field. I've tried numerous suggestions that I've seen in newsgroups and everything either gives an error or puts 1/1/1900 in the field. The code I'm trying is: Dim sqlCMD As New SqlClient.SqlCommand("Insert Into tblNotificationStatus (UserName, ExpirationDate) values ('" & strUser & "','" &...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10320
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.