473,795 Members | 2,605 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 3067
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
6706
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
1798
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
1650
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
3504
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
7544
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
1385
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
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
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
5436
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...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.