473,326 Members | 2,173 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,326 software developers and data experts.

datatype error

al
Hi , I am trying to update a table in the database:
I am getting error and I assume cause of the error is
because datatype for the ownership table does not match
the parameter so I am not sure how to fix it. any help
thanks
Al

table structure is as follow:
partnership_investor_id int
partnership_id int
investor_id int
ownership numeric(18,9)
The code to update is as follow:

as you can see when I declared parameter, I had to put
sqlDbType to varchar for ownership field. I
Sub dg_UpdateRow(sender As Object, e As
DataGridCommandEventArgs)
'Get information from columns...
Dim ddlPartnershipS as DropDownList = e.Item.Cells
(3).FindControl("ddlPartnership")
Dim ddlInvestorS as DropDownList = e.Item.Cells
(4).FindControl("ddlInvestor")
Dim OwnershipTextBox as TextBox = e.Item.Cells
(5).Controls(0)
Dim tblPK as String = dg.DataKeys(e.Item.ItemIndex)

'Update the database...
Dim strSQL as String
strSQL = "UPDATE partnership_investor " & _
" SET partnership_id = @Partnership_IdPara, Investor_id =
@Investor_IdPara, " & _
"Ownership = @OwnershipPara " & _
"WHERE partnership_investor_id =
@partnership_investor_idPara"

SQLStatement.Text= strSQL

Dim objCmd as New SqlCommand(SQLStatement.Text, objConn)
'declare parameterDim partnership_investor_idPara as New
SqlParameter("@partnership_investor_idPara",
SqlDbType.Char, 4)

Dim Partnership_IdPara as New SqlParameter
("@Partnership_IdPara", SqlDbType.Char, 4)
Dim Investor_IdPara as New SqlParameter
("@Investor_IdPara", SqlDbType.Char, 4)
Dim OwnershipPara as New SqlParameter
("@OwnershipPara", SqlDbType.VarChar, 15)

'populate para
partnership_investor_idPara.Value = tblPK
objCmd.Parameters.Add(partnership_investor_idPara)

Partnership_IdPara.Value =
ddlPartnershipS.SelectedItem.Value
objCmd.Parameters.Add(Partnership_IdPara)

Investor_IdPara.Value = ddlInvestorS.SelectedItem.Value
objCmd.Parameters.Add(Investor_IdPara)

OwnershipPara.Value = OwnershipTextBox.Text
objCmd.Parameters.Add(OwnershipPara)
'Issue the SQL command
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()

dg.EditItemIndex = -1
BindData()
End Sub
Nov 18 '05 #1
0 840

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

Similar topics

2
by: Stephen Briley | last post by:
For some reason, my posts are scrubbed as attachments. Lets hope that sending from the yahoo account works. I'm new to Python and I'm trying to do some database work with MS Access, but I can't...
2
by: Steve Briley | last post by:
I'm new to Python and I'm trying to do some database work with MS Access, but I can't seem to get around a "datatype mismatch error".  Here's an example table that I'm working with... ...
4
by: J.C. Flores | last post by:
Hello all, First of all, I must state that I'm new to SQL Server, but have been a long-time software guy for quite some time. Please excuse the potential simplicity of the solution to my...
1
by: al | last post by:
hi, I have a table that contain a field "amount" its datatype is numeric(18,4) in sql server 2000 I have created a Datagrid, when I edit a record, I get an error like this one BC30456:...
2
by: Johan Delimon | last post by:
"The active directory datatype cannot be converted to/from a native DS datatype" I have an ASP.NET web page that uses queries to AD to identify current users. Delegation is configured in AD and...
1
by: Prabu Subroto | last post by:
Dear my friends... I want to change the datatype of a completed table (has had already content). But I don't know how. Here is my try: " kv=# alter table customer alter column address set...
1
by: Praveen | last post by:
HI, I have a table with IDENTITY column with the datatype as INTEGER. Now this table record count is almost reaching its limt. that is total record count is almost near to 2^31-1. It will reach...
0
by: vijayalakshmi.venkataraman | last post by:
Hello, I have a .NET client that accesses a Java webservice. Let me first say that the client stub I got generated from the wsdl was incomplete and had to make changes to it manually to make it...
1
by: Jay Balapa | last post by:
Hello, Iam trying to do the following- if(myColumn.DataType==typeof(bool)) { } this does not work either Type.GetType("System.Boolean") instead of typeof(bool).
1
by: reliance | last post by:
Using Oracle Migration Workbench, I migrated ms-access 2003 database to oracle 9i. The memo datatype in ms-access mapped to clob datatype in oracle. I have created a system dsn to access oracle...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.