473,408 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

adding record to sql db

hello all...

im trying to add a record to an sql db on ms sql server 2000, using vb.net.

seems to be working.. except for one thing, one of the columns in the
database is a bit datatype, and though i get no syntax errors when
compiling, i get an error indicated that the data would be truncated. the
field is login_status.

ive tried in quotes and not, giving it an integer variable with the number 1
in it, true/false statements.. ive tried a bunch of stuff... has me real
stumped..

have any ideas?

thanks
here is the error it spits out.

<b>* error while uploading original data</b>.<br />String or binary data
would be truncated.The statement has been terminated..Net SqlClient Data
Provider


--------------------------------------------------------------------------
here is the code:
--------------------------------------------------------------------------
Imports System.Data

Imports System.Data.SqlClient

Public Class WebForm1

Inherits System.Web.UI.Page




Public Sub Register_User(ByVal sender As Object, ByVal E As EventArgs)

Dim dbConnStr As String = "user id=**(blanked for
security)***;password=**(blanked for
security)**;database=BCdb;server=localhost"

Dim dbConn As New System.Data.SqlClient.SqlConnection(dbConnStr)



Try

Dim cmd As New SqlCommand("addCustomerSQL", dbConn)

cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add(New SqlParameter("@username", SqlDbType.Char, 19))

cmd.Parameters.Add(New SqlParameter("@fullname", SqlDbType.VarChar, 27))

cmd.Parameters.Add(New SqlParameter("@password", SqlDbType.Char, 7))

cmd.Parameters.Add(New SqlParameter("@credit_card_nbr", SqlDbType.Char, 18))

cmd.Parameters.Add(New SqlParameter("@credit_card_expiry_date",
SqlDbType.DateTime))

cmd.Parameters.Add(New SqlParameter("@mailing_address", SqlDbType.VarChar,
100))

cmd.Parameters.Add(New SqlParameter("@phone_nbr", SqlDbType.Char, 14))

cmd.Parameters.Add(New SqlParameter("@email_address", SqlDbType.Char, 50))

cmd.Parameters.Add(New SqlParameter("@login_status", SqlDbType.Bit))

cmd.Parameters.Add(New SqlParameter("@credit_card_name", SqlDbType.Char,
27))

cmd.Parameters.Item("@username").Value = RegUsrnameTXT.Text

cmd.Parameters.Item("@fullname").Value = RegFullnameTXT.Text

cmd.Parameters.Item("@password").Value = RegPasswordTXT.Text

cmd.Parameters.Item("@credit_card_nbr").Value = RegCreditcardnumberTXT.Text

cmd.Parameters.Item("@credit_card_expiry_date").Va lue =
RegCreditcardexpiryTXT.Text

cmd.Parameters.Item("@mailing_address").Value = RegAddressTXT.Text

cmd.Parameters.Item("@email_address").Value = RegEmailTXT.Text

cmd.Parameters.Item("@phone_nbr").Value = RegPhoneTXT.Text

cmd.Parameters.Item("@login_status").Value = 1

cmd.Parameters.Item("@credit_card_name").Value = RegCreditcardnameTXT.Text

'opent the connection to the database

dbConn.Open()

'execute sql statement

cmd.ExecuteNonQuery()

dbConn.Close()

Catch objError As Exception

dberror.Text = "<b>* error while uploading original data</b>.<br />" &
objError.Message & objError.Source

Exit Sub

Finally

If dbConn.State = ConnectionState.Open Then

dbConn.Close()

End If

End Try

End Sub

End Class

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

Nov 20 '05 #1
0 1080

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

Similar topics

6
by: Jamie Fryatt | last post by:
Hi everyone, here's what id like to do. I have a table with 2 fields, name and value I need to be able to add multiple records quickly, for example I need to add name value abc 1...
2
by: brenda.stow | last post by:
error msg " An error occured while referencing the object. You tried to run a visual basic procedure that improperly references a property or method of an object" This msg occurs everytime I add a...
2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
9
by: Greg | last post by:
Binding Manager & dataset - won't add record I've got an untyped dataset with controls bound through code. The user can select a question number from a bound combobox, and the question number and...
6
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire...
8
by: shumaker | last post by:
I'm wondering if adding an autonumber primary key will improve the performance of a multiuser access database on a network share. I have a website that lists many tips for improving performance of...
3
by: john | last post by:
In my form (table A) I have subform (table B (only 2 fieds: ID and App_name) where table A -Table B are linked 1XM. To be able to add a record in the subform I want to use a lookup form since the...
1
by: tonylove42 | last post by:
HI, I have probelm adding, updating and deleteing a record. Here is my code for adding . The error I get is: Operation must use an updateable query. Line 135: MyCmd.ExecuteNonQuery() ...
1
by: ConfusedMay | last post by:
Hi, I'm working on a database that has a form which hold all of our products testing. each product can hold more than 1 complete test (complete test here means that product has to have before and...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...
0
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...

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.