After executing this code , I get no errors , but nothing is added to the database !
Code:Dim MyCmd As SqlCommand = New SqlCommand() MyCmd.CommandText = "insNewComplain" MyCmd.CommandType = Data.CommandType.StoredProcedure MyCmd.Parameters.Clear() MyCmd.Parameters.Add("@TypeID", SqlDbType.Int) MyCmd.Parameters.Add("@LocationID", SqlDbType.Int) MyCmd.Parameters.Add("@MobileNO", SqlDbType.Char) MyCmd.Parameters.Add("@CallerNO", SqlDbType.Char) MyCmd.Parameters.Add("@CallerName", SqlDbType.Char) MyCmd.Parameters.Add("@ComplainDetails", SqlDbType.Text) MyCmd.Parameters.Add("@ImportanceID", SqlDbType.Int) MyCmd.Parameters.Add("@DeathID", SqlDbType.Int) MyCmd.Parameters.Add("@StreetID", SqlDbType.Int) '----------------------------------------------------------- MyCmd.Parameters("@LocationID").Value = LocationsComboBox.SelectedValue MyCmd.Parameters("@TypeID").Value = ComplainTypeComboBox.SelectedValue MyCmd.Parameters("@MobileNO").Value = txtCallerMobile.Text MyCmd.Parameters("@CallerNO").Value = txtCallerNO.Text MyCmd.Parameters("@CallerName").Value = txtCallerName.Text MyCmd.Parameters("@ComplainDetails").Value = txtComplainDetails.Text MyCmd.Parameters("@ImportanceID").Value = ImportanceComboBox.SelectedValue MyCmd.Parameters("@DeathID").Value = 1 'HERE YOU HAVE TO STORE THE RADIO BUTTON OPTION MyCmd.Parameters("@StreetID").Value = StreetsComboBox.SelectedValue MyConn = New SqlConnection MyCmd.Connection = MyConn MyConn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MYDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" MyConn.Open() MyCmd.ExecuteNonQuery() Catch MessageBox.Show("Unable to Execute SQL " & Err.Description) Exit Sub End Try Catch Exit Sub End Try MessageBox.Show("INSERT WAS SUCCESSFUL!") MyConn.Close() MyCmd = Nothing
and here is my stored procedure:
Code:ALTER PROCEDURE dbo.insNewComplain @TypeID int , @LocationID int, @MobileNO char(10), @CallerNO char(10), @CallerName varchar(50), @ComplainDetails text, @ImportanceID int, @DeathID int, @StreetID int AS INSERT INTO Complains(TypeID, LocationID, MobileNO, CallerNO, CallerName, ComplainDate, ComplainDetails, ImportanceID, DeathID, StreetID) VALUES (@TypeID, @LocationID, @MobileNO, @CallerNO, @CallerName, getDate (),@ComplainDetails, @ImportanceID, @DeathID, @StreetID)




Reply With Quote