btp111
Starting Member
6 Posts |
Posted - 2008-05-06 : 10:46:14
|
Hi,This is my first posting and I am new to doing any development and have some simple code that I am having issues with. Details below:1)SQL Stored Procedure with Parameters:CREATE PROCEDURE InsIA @mjedln float(8), @mjedoc float(8),@mjitm float(8),@mjlocn char(20) ASINSERT INTO table1 (MJEKCO, MJEDCT,MJEDLN,MJEDOC,MJPACD, MJAN8,MJMCU,MJITM,MJLITM,MJAITM,MJLOCN,MJTRNO,MJTRUM,MJTRQT,MJMMCU,MJKCO,MJDCT,MJDCTO,MJTREX,MJRCD)VALUES ('02000','IA',@mjedln,@mjedoc,'QT',2000.000000,' 2000',@mjitm,'7211A-SCV-A101','7211A-SCV-A101',@mjlocn,1.000000,'EA',-10.000000,' 2000','02000','IA','IA','EWAAERWGF','002')INSERT INTO table2 (M1EKCO,M1EDCT,M1EDST,M1EDOC,M1AN8)VALUES ('02000','IA','852',10682007.000000,2000.000000)GO**As you can see I have a few parameters. The one I am having an issue with is @mjlocn for Table 1. The other parameters work well. The other parameters update fields that are FLOAT fields and the one I am having issues with updates a Char field.2)Below is my code to pass Parameters to the stored procedure upon clicking a Button in Access:Private Sub cmdupdate_Click() Dim LocalConnection As ADODB.ConnectionDim cn As New ADODB.ConnectionDim cmd As New ADODB.CommandDim rs As New ADODB.RecordsetDim line As VariantDim docnumber As VariantDim prm As ADODB.ParameterDim prm2 As ADODB.ParameterDim item As VariantDim itm As ADODB.Parameter'Dim mjlitm As ADODB.Parameter'Dim longitem As String'Dim mjaitm As ADODB.Parameter'Dim longitem2 As StringDim mjlocn As ADODB.ParameterDim location As Stringcn.Provider = "sqloledb"cn.Properties("Data Source").Value = "HLAERP1"cn.Properties("Initial Catalog").Value = "PS_CRP"cn.Properties("Integrated Security").Value = "SSPI"cn.OpenSet cmd.ActiveConnection = cncmd.CommandText = "insIA"cmd.CommandType = adCmdStoredProccmd.CommandTimeout = 15Set prm = cmd.CreateParameter("InputLineNumber", adInteger, adParamInput)cmd.Parameters.Append prmline = Text14.Valueprm.Value = lineSet prm2 = cmd.CreateParameter("InputDocNumber", adInteger, adParamInput)cmd.Parameters.Append prm2docnumber = Text16.Valueprm2.Value = docnumberSet itm = cmd.CreateParameter("InputItemNum", adInteger, adParamInput)cmd.Parameters.Append itmitem = IBITM.Valueitm.Value = itemSet mjlocn = cmd.CreateParameter("InputLocation", adChar, adParamInput)cmd.Parameters.Append mjlocnlocation = LILOCN.Valuemjlocn.Value = locationSet rs = cmd.Executecn.CloseEnd SubAll parameters work great except for the one in italics which is mjlocn. I get the following error after adding this one:Run Time Error: 3708Parameter object is improperly defined. Inconsisten or incomplete info provided.However, I don't have any idea why because I am using the same logic as I did on the float fields (except for parameter type I chose adInteger on those) except I chose adChar for the type of the parameter but I thought that would be correct since they are CHAR format in the table I am inserting to. Any ideas would be greatly appreciated.Thanks in advance. |
|