Please help Stored Proc

theboy_20001
11-02-2004, 12:38 PM
this is my vb code:

With cmd1
.CommandTimeout = 0
.ActiveConnection = conn
.CommandType = adCmdStoredProc
.CommandText = "spImage_Add_To_DataBase"
.Parameters.Append .CreateParameter("@Image_Type_Ident", adInteger, adParamInput, , cboTypeDoc.ListIndex)
.Parameters.Append .CreateParameter("@Image_Sub_Type_Ident", adInteger, adParamInput, , Right(cboFormType.Text, 1))
.Parameters.Append .CreateParameter("@Full_Path", adVarChar, adParamInput, , strCurrentPicture)
.Parameters.Append .CreateParameter("@Image_Name", adVarChar, adParamInput, , CurrentFileName)
.Parameters.Append .CreateParameter("@Orig_Name", adVarChar, adParamInput, , CurrentFileName)
End With
With rs
.Fields.Append "@Image_Type_Idnet", adInteger, , adFldIsNullable
.Fields.Append "@Image_Sub_Type_Ident", adInteger, , adFldIsNullable
.Fields.Append "@Full_Path", adChar, , adFldIsNullable
.Fields.Append "@Image_Name", adChar, , adFldIsNullable
.Fields.Append "@Orig_Name", adChar, , adFldIsNullable
.Open
.AddNew
.Fields("@Image_Type_Idnet") = cboTypeDoc.ListIndex
.Fields("@Image_Sub_Type_Ident") = Right(cboFormType.Text, 1)
.Fields("@Full_Path") = strCurrentPicture
.Fields("@Image_Name") = CurrentFileName
.Fields("@Orig_Name") = CurrentFileName
.Update
.MoveFirst
End With

rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing


this is the stored procedure:

CREATE procedure spImage_Add_to_Database

@Image_Type_Ident int,
@Image_Sub_Type_Ident int,
@Full_Path varchar(200),
@Image_Name varchar(200),
@Orig_Name varchar(200)

as

Update

Image

set

Image_Type_Ident = @Image_Type_Ident,
Image_Sub_Type_Ident = @Image_Sub_Type_Ident,
Full_Path = @Full_Path,
Image_Name = @Image_Name,
Orig_Image_Name = @Orig_Name
GO

i get errors that it cannot find the fields for the last 3 parameters.

Dennis DVR
11-02-2004, 11:28 PM
this is my vb code:

With cmd1
.CommandTimeout = 0
.ActiveConnection = conn
.CommandType = adCmdStoredProc
.CommandText = "spImage_Add_To_DataBase"
.Parameters.Append .CreateParameter("@Image_Type_Ident", adInteger, adParamInput, , cboTypeDoc.ListIndex)
.Parameters.Append .CreateParameter("@Image_Sub_Type_Ident", adInteger, adParamInput, , Right(cboFormType.Text, 1))
.Parameters.Append .CreateParameter("@Full_Path", adVarChar, adParamInput, , strCurrentPicture)
.Parameters.Append .CreateParameter("@Image_Name", adVarChar, adParamInput, , CurrentFileName)
.Parameters.Append .CreateParameter("@Orig_Name", adVarChar, adParamInput, , CurrentFileName)
End With
With rs
.Fields.Append "@Image_Type_Idnet", adInteger, , adFldIsNullable
.Fields.Append "@Image_Sub_Type_Ident", adInteger, , adFldIsNullable
.Fields.Append "@Full_Path", adChar, , adFldIsNullable
.Fields.Append "@Image_Name", adChar, , adFldIsNullable
.Fields.Append "@Orig_Name", adChar, , adFldIsNullable
.Open
.AddNew
.Fields("@Image_Type_Idnet") = cboTypeDoc.ListIndex
.Fields("@Image_Sub_Type_Ident") = Right(cboFormType.Text, 1)
.Fields("@Full_Path") = strCurrentPicture
.Fields("@Image_Name") = CurrentFileName
.Fields("@Orig_Name") = CurrentFileName
.Update
.MoveFirst
End With

rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing


this is the stored procedure:

CREATE procedure spImage_Add_to_Database

@Image_Type_Ident int,
@Image_Sub_Type_Ident int,
@Full_Path varchar(200),
@Image_Name varchar(200),
@Orig_Name varchar(200)

as

Update

Image

set

Image_Type_Ident = @Image_Type_Ident,
Image_Sub_Type_Ident = @Image_Sub_Type_Ident,
Full_Path = @Full_Path,
Image_Name = @Image_Name,
Orig_Image_Name = @Orig_Name
GO

i get errors that it cannot find the fields for the last 3 parameters.

what part of the code is causing error? and why do you need to create a disconnected recordset? and the Execute method of cmd1 command object is not even called in your program, and you are saving CurrentFileName instead of strCurrentFileName is it really CurrentFileName? :confused:

btw: do you have Option Explicit On in your code

theboy_20001
11-03-2004, 07:37 AM
Yeah i figured it out this code was totallly wrong. I am new to stroed procs. I have it working now though. Thanks for looking at it.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum