473,756 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Sql Client

Public Class WebForm1

Inherits System.Web.UI.P age




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

Dim dbConnStr As String = "user id=**(blanked for
security)***;pa ssword=**(blank ed for
security)**;dat abase=BCdb;serv er=localhost"

Dim dbConn As New System.Data.Sql Client.SqlConne ction(dbConnStr )



Try

Dim cmd As New SqlCommand("add CustomerSQL", dbConn)

cmd.CommandType = CommandType.Sto redProcedure

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

cmd.Parameters. Add(New SqlParameter("@ fullname", SqlDbType.VarCh ar, 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_exp iry_date",
SqlDbType.DateT ime))

cmd.Parameters. Add(New SqlParameter("@ mailing_address ", SqlDbType.VarCh ar,
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_nam e", SqlDbType.Char,
27))

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

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

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

cmd.Parameters. Item("@credit_c ard_nbr").Value = RegCreditcardnu mberTXT.Text

cmd.Parameters. Item("@credit_c ard_expiry_date ").Value =
RegCreditcardex piryTXT.Text

cmd.Parameters. Item("@mailing_ address").Value = RegAddressTXT.T ext

cmd.Parameters. Item("@email_ad dress").Value = RegEmailTXT.Tex t

cmd.Parameters. Item("@phone_nb r").Value = RegPhoneTXT.Tex t

cmd.Parameters. Item("@login_st atus").Value = 1

cmd.Parameters. Item("@credit_c ard_name").Valu e = RegCreditcardna meTXT.Text

'opent the connection to the database

dbConn.Open()

'execute sql statement

cmd.ExecuteNonQ uery()

dbConn.Close()

Catch objError As Exception

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

Exit Sub

Finally

If dbConn.State = ConnectionState .Open Then

dbConn.Close()

End If

End Try

End Sub

End Class

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

Nov 20 '05
20 2143
"Bryan" <ca**********@r ogers.com> wrote in message news:<5y******* *************@n ews04.bloor.is. net.cable.roger s.com>...
hello all...

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


Bryan,

I noticed two things. First you are allowing null values in the bit
field, this is bad form as well as bad logic. Second, the next line
(from your code) seems to be missing a value:

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

HTH,

Charlie
Nov 20 '05 #21

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

Similar topics

6
2413
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 abc 2 abc 3
2
5788
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 new record to a subform. If I close msgbox I can then successfully add new record. Have looked on MS Technet and tried their 2 suggestions:- 1)LinkChildFields property contains the name of a form property - this isn't the case linkChildFields...
2
3639
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 a row. Everything works just fine. BUT I would like to add a button to (for example) the DataGrid header, which when pressed will add a new row to the datagrid. This should then allow the user to enter information into text boxes (in some...
3
4884
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 the best method? Do you have a sample of how to do this?
9
424
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 question text are displayed in bound textboxes. This part works fine. When I go to add a new record, the textboxes clear as they should. I enter a new question number and tab to the textbox for the question text. At this point, the text for the...
6
4430
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 row doesn't get filled. I have a connection and all that stuff. Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaceBet.Click ' Dim Myds As Footbet.DStable '...
8
3272
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 access, but doesn't mention primary keys. However, it seems logical to think that having no primary key means that when a user updates a record, the database has to do comparisons on multiple fields to identify the specific record being...
3
5350
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 number of possible values is over 300. For data consistancy I've locked the subform so that the user can't add or change values manually without using the lookup form. My question is: What's the best way of adding the record to table B which the...
1
1226
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() I get same error for update and delete. here is my code for adding: MySQL = "INSERT INTO Property " & _ "(PropAddress, PropCity, PropSuburb, PropType, " & _
1
2637
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 after standard tests) This database is created in access 97. The form has 2 portion which is "before standard test" and "after standard test". What I need is when user does product test, user has to enter before and after standard tests textboxes....
0
9275
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
9872
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...
1
9843
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
8713
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
7248
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
5142
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
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.