473,698 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Input string incorrect format

Here is my code below. I recieve this error when I run

MyCommand.Selec tCommand.Execut eNonQuery()

Thanks. Big E

Sub MyDataGrid_Upda te(ByVal Sender As Object, ByVal E As
DataGridCommand EventArgs)

Dim DS As DataSet

Dim Portal As String =
ConfigurationSe ttings.AppSetti ngs("Portal.Con nectionString")

Dim cnPortal As SqlConnection = New SqlConnection(P ortal)

Dim MyCommand As SqlDataAdapter = New SqlDataAdapter( "spDGAnswer_Upd ate",
cnPortal)

MyCommand.Selec tCommand.Comman dType = CommandType.Sto redProcedure

MyCommand.Selec tCommand.Parame ters.Add(New SqlParameter("@ AnswerId",
SqlDbType.Int))

MyCommand.Selec tCommand.Parame ters.Add(New SqlParameter("@ AnswerDesc",
SqlDbType.VarCh ar, 50))

MyCommand.Selec tCommand.Parame ters.Add(New SqlParameter("@ SortOrder",
SqlDbType.TinyI nt))

MyCommand.Selec tCommand.Parame ters("@AnswerId ").Value =
MyDataGrid.Data Keys(CInt(E.Ite m.ItemIndex))

Dim Cols As String() = {"@AnswerId" , "@AnswerDes c", "@SortOrder "}

Dim NumCols As Integer = E.Item.Cells.Co unt

Dim I As Integer

For I = 1 To NumCols - 1 'skip first, second and last column

Dim CurrentTextBox As TextBox

CurrentTextBox = E.Item.Cells(I) .Controls(0)

Dim ColValue As String = CurrentTextBox. Text

MyCommand.Selec tCommand.Parame ters(Cols(I - 1)).Value =
Server.HtmlEnco de(ColValue)

Next

MyCommand.Selec tCommand.Connec tion.Open()

Try

MyCommand.Selec tCommand.Execut eNonQuery()

MyDataGrid.Edit ItemIndex = -1

Catch Exp As SqlException

If Exp.Number = 2627 Then

Message.InnerHt ml = "ERROR: A record already exists with the same primary
key"

' Else

' Message.InnerHt ml = "ERROR: Could not update record, please ensure the
fields are correctly filled out"

End If

Message.Style(" color") = "red"

End Try

MyCommand.Selec tCommand.Connec tion.Close()

BindGrid()

End Sub
Nov 18 '05 #1
1 1908
look at the SelectCommand, what's it's SQL statement look like? the SPROC if
it's using.
Are the params you are passing in the right TYPE?

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Big E" <no****@nospam. com> wrote in message
news:OF******** ******@TK2MSFTN GP12.phx.gbl...
Here is my code below. I recieve this error when I run

MyCommand.Selec tCommand.Execut eNonQuery()

Thanks. Big E

Sub MyDataGrid_Upda te(ByVal Sender As Object, ByVal E As
DataGridCommand EventArgs)

Dim DS As DataSet

Dim Portal As String =
ConfigurationSe ttings.AppSetti ngs("Portal.Con nectionString")

Dim cnPortal As SqlConnection = New SqlConnection(P ortal)

Dim MyCommand As SqlDataAdapter = New SqlDataAdapter( "spDGAnswer_Upd ate",
cnPortal)

MyCommand.Selec tCommand.Comman dType = CommandType.Sto redProcedure

MyCommand.Selec tCommand.Parame ters.Add(New SqlParameter("@ AnswerId",
SqlDbType.Int))

MyCommand.Selec tCommand.Parame ters.Add(New SqlParameter("@ AnswerDesc",
SqlDbType.VarCh ar, 50))

MyCommand.Selec tCommand.Parame ters.Add(New SqlParameter("@ SortOrder",
SqlDbType.TinyI nt))

MyCommand.Selec tCommand.Parame ters("@AnswerId ").Value =
MyDataGrid.Data Keys(CInt(E.Ite m.ItemIndex))

Dim Cols As String() = {"@AnswerId" , "@AnswerDes c", "@SortOrder "}

Dim NumCols As Integer = E.Item.Cells.Co unt

Dim I As Integer

For I = 1 To NumCols - 1 'skip first, second and last column

Dim CurrentTextBox As TextBox

CurrentTextBox = E.Item.Cells(I) .Controls(0)

Dim ColValue As String = CurrentTextBox. Text

MyCommand.Selec tCommand.Parame ters(Cols(I - 1)).Value =
Server.HtmlEnco de(ColValue)

Next

MyCommand.Selec tCommand.Connec tion.Open()

Try

MyCommand.Selec tCommand.Execut eNonQuery()

MyDataGrid.Edit ItemIndex = -1

Catch Exp As SqlException

If Exp.Number = 2627 Then

Message.InnerHt ml = "ERROR: A record already exists with the same primary
key"

' Else

' Message.InnerHt ml = "ERROR: Could not update record, please ensure the
fields are correctly filled out"

End If

Message.Style(" color") = "red"

End Try

MyCommand.Selec tCommand.Connec tion.Close()

BindGrid()

End Sub

Nov 18 '05 #2

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

Similar topics

9
4057
by: Arnold | last post by:
I need to read a binary file and store it into a buffer in memory (system has large amount of RAM, 2GB+) then pass it to a function. The function accepts input as 32 bit unsigned longs (DWORD). I can pass a max of 512 words to it at a time. So I would pass them in chunks of 512 words until the whole file has been processed. I haven't worked with binary files before so I'm confused with how to store the binary file into memory. What sort of...
7
10651
by: Don Riesbeck Jr. | last post by:
I'm working on an application (OEM) using C# that utilizes input from a keyboard, and USB Barcode Scanner. The scanner is a HID Keyboard device, and input from it is sent to the system as if it were a keyboard. I need to be able to identify input from the scanner and keyboard independently. I've looked at DirectX.DirectInput, and using user32.dll to hook into the keyboard messages, but neither method seems to allow for identification of...
6
2101
by: JohnnyW | last post by:
Hello, I have I simple question that is not clear for me. So, I have a input field (text field) in my html page. User should give input as a string like following 12 345 678,0 If user gives input in format 12345678,0 and leves the input field how can I format the value 12345678,0 into format 12 345 678,0? Are there any Javascript that can handle this with Regular Expressions?
0
2542
by: hudhuhandhu | last post by:
have got an error which says Input string was not in a correct format. as follows.. 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: System.FormatException: Input string was not in a correct format. Source Error: Line 237: Dim validNow As Integer = 1 Line...
0
11983
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the form controls so
0
3163
by: sehguh | last post by:
Hiya Folks, I am Currently using windows xp. Also using Visual Web Developer 2005 and Microsoft Sql server 2005. The main page consists of an aspx page and a master page. The page also consists of a label control(hidden when run in browser). Also an Sql data source control connected to database tables for a photo album. Also label web control ID=UserIdValue. Also a Details View control ID=dvPictureInsert Problem is how to work out...
1
2398
by: ndawg123 | last post by:
Hey guys what im trying to do is write a yatzee game with C. And im stuck already and its the start?!?! I want the user to type there 5 numbers. i.e My program so far does this Please enter dice Values:
2
2073
abehm
by: abehm | last post by:
Hey everyone, I'm trying to input a string as an xml data type into sql server, but i keep getting this error. Am I doing this incorrectly, or do i need to format the string? XmlDocument mydoc = new XmlDocument(); SqlCommand sqlCommand; mydoc.Load(xmlDir + "temp.xml"); string tempXML = mydoc.OuterXml;
6
4051
abehm
by: abehm | last post by:
Hey everyone, I'm trying to input a string as an xml data type into sql server, but i keep getting this error. Am I doing this incorrectly, or do i need to format the string? XmlDocument mydoc = new XmlDocument(); SqlCommand sqlCommand; mydoc.Load(xmlDir + "temp.xml");
5
1639
by: semomaniz | last post by:
The problem that i am having is when ever i input text in format like O'Neal as lastname then my code breaks and gives me following error Incorrect syntax near 'Neal'. Unclosed quotation mark before the character string ''. If i remove ( ' ) from the Input the code works. How do i solve this? Please advice. string strSql = " Update Drivers SET CarrierID =@carrierid, LastName =@lastname, FirstName =@firstname, Address =@address,...
0
8674
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
8603
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
9157
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
8895
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
7725
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
6518
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
4369
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2001
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.