Hi I have a gridview that is being populated from a method that gets it's data from a table view.
SELECT dbo.cis_AlumniContact.Street, dbo.cis_AlumniContact.City, dbo.cis_AlumniContact.State, dbo.cis_AlumniContact.Telephone,
dbo.cis_AlumniContact.Occupation, dbo.cis_AlumniContact.Description, dbo.cis_AlumniContact.Zip, dbo.cis_AlumniContact.FirstName,
dbo.cis_AlumniContact.LastName, dbo.cis_AlumniContact.YearGraduate, dbo.cis_AlumniContact.Email, dbo.cis_AlumniContact.Contact,
dbo.aspnet_Users.UserName, dbo.cis_StudentId.UaaStudentId
FROM dbo.aspnet_Users INNER JOIN
dbo.cis_AlumniContact ON dbo.aspnet_Users.UserId = dbo.cis_AlumniContact.UserId INNER JOIN
dbo.cis_StudentId ON dbo.aspnet_Users.UserId = dbo.cis_StudentId.UserId
No big deal, works great. Now when I click update I call this method
PublicSub UpdateAlumni(ByVal StreetAsString,ByVal CityAsString,ByVal StateAsString,ByVal TelephoneAsString,ByVal OccupationAsString,ByVal DescriptionAsString,ByVal ZipAsString,ByVal FirstNameAsString,ByVal LastNameAsString,ByVal YearGraduateAsString,ByVal EmailAsString,ByVal ContactAsBoolean,ByVal original_UserNameAsString,ByVal UaaStudentIdAsString)TryDim connxAsNew SqlConnection(getConnectionString)<DataObjectMethod(DataObjectMethodType.Update)>
connx.Open()
Dim sqlCmdAsNew SqlCommand("cis_UpdateAlumniContact", connx)sqlCmd.Parameters.Add(
New SqlParameter("@.UserName", SqlDbType.NVarChar))sqlCmd.Parameters(
"@.UserName").Value = original_UserNamesqlCmd.Parameters.Add(
New SqlParameter("@.FirstName", SqlDbType.NVarChar))sqlCmd.Parameters(
"@.FirstName").Value = FirstNamesqlCmd.Parameters.Add(
New SqlParameter("@.LastName", SqlDbType.NVarChar))sqlCmd.Parameters(
"@.LastName").Value = LastNamesqlCmd.Parameters.Add(
New SqlParameter("@.Email", SqlDbType.NVarChar))sqlCmd.Parameters(
"@.Email").Value = EmailsqlCmd.Parameters.Add(
New SqlParameter("@.Street", SqlDbType.NVarChar))sqlCmd.Parameters(
"@.Street").Value = StreetsqlCmd.Parameters.Add(
New SqlParameter("@.City", SqlDbType.NVarChar))sqlCmd.Parameters(
"@.City").Value = CitysqlCmd.Parameters.Add(
New SqlParameter("@.State", SqlDbType.NVarChar))sqlCmd.Parameters(
"@.State").Value = StatesqlCmd.Parameters.Add(
New SqlParameter("@.Occupation", SqlDbType.NVarChar))sqlCmd.Parameters(
"@.Occupation").Value = OccupationsqlCmd.Parameters.Add(
New SqlParameter("@.Description", SqlDbType.NVarChar))sqlCmd.Parameters(
"@.Description").Value = DescriptionsqlCmd.Parameters.Add(
New SqlParameter("@.Telephone", SqlDbType.NChar))sqlCmd.Parameters(
"@.Telephone").Value = TelephonesqlCmd.Parameters.Add(
New SqlParameter("@.Zip", SqlDbType.NChar))sqlCmd.Parameters(
"@.Zip").Value = ZipsqlCmd.Parameters.Add(
New SqlParameter("@.Contact", SqlDbType.Bit))sqlCmd.Parameters(
"@.Contact").Value = ContactsqlCmd.Parameters.Add(
New SqlParameter("@.YearGraduate", SqlDbType.NVarChar))sqlCmd.Parameters(
"@.YearGraduate").Value = YearGraduateDim cmdAs SqlDataReader = sqlCmd.ExecuteReaderCatch exAs ExceptionDim erAsNew cis_ODS_Errorer.InsertError(
"cis_ODS_Alumni - UpdateAlumni: " + ex.Message.ToString)EndTryEndSubThe sproc it calls is:
dbo.cis_UpdateAlumniContactALTER PROCEDURE
@.UserName
as nvarchar(50),@.Street
as nvarchar(50),@.City
as nvarchar(50),@.State
as nvarchar(2),@.Telephone
as nvarchar(50),@.Occupation
as nvarchar(50),@.Description
as nvarchar(50),@.Zip
as nvarchar(50),@.FirstName
as nvarchar(50),@.LastName
as nvarchar(50),@.YearGraduate
as nvarchar(4),@.Contact
as bitAS
UPDATEcis_AlumniContactSETStreet = @.Street, City = @.City, State = @.State, Telephone = @.Telephone, Occupation = @.Occupation, Description = @.Description, Zip = @.Zip, FirstName = @.FirstName, LastName = @.LastName, YearGraduate = @.YearGraduate, Email = @.Email, Contact = @.Contact
FROMaspnet_UsersINNER JOINcis_AlumniContact
ONcis_AlumniContact.UserId = aspnet_Users.UserId
WHERE@.UserName = aspnet_Users.UserName
RETURN
I get this vague error
cis_ODS_Alumni - UpdateAlumni: Incorrect syntax near 'cis_UpdateAlumniContact'
If I execute the SQL from the editor it works fine. The only thing different about this sproc and my other update sprocs is the inner join. Any idea? Thanks
I see two possible problems.
You need to set the command type to:StoredProcedure
You are calling ExecuteReader, I think you need to call ExecuteNonQuery.
|||Holy cow man. Thanks so much. I copied and pasted from another method and didn't include that line. Thanks again.
No comments:
Post a Comment