By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,009 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,009 IT Pros & Developers. It's quick & easy.

Solve this and replay me i hunged here

P: 6
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.SqlClient
  2. Namespace Accounts
  3.     Public Class NewAccount
  4.         Dim cmd As New SqlCommand
  5.         Dim c As New DatabaseConnection.DataBaseConnaction.ConnectionClass
  6.         Function CreateAccount(ByVal BankID As String, ByVal Account_TypeID As String, ByVal First_Name As String, ByVal Last_Name As String, ByVal Date_Birth As DateTime, ByVal Citizenship As String, ByVal Civil_Id As Integer, ByVal address As String, ByVal Father_Name As String, ByVal Profession As String, ByVal Description As String, ByVal Date_creation As DateTime, ByVal phoneNo As String, ByVal emailid As String, ByVal ext As String, ByVal CreatedBy As String, ByVal UserID As String)
  7.             Try
  8.                 cmd.Parameters.Add("@BankID", SqlDbType.VarChar)
  9.                 cmd.Parameters.Item("@BankID").Value = BankID
  10.  
  11.                 cmd.Parameters.Add("@Account_TypeID", SqlDbType.VarChar)
  12.                 cmd.Parameters.Item("@Account_TypeID").Value = Account_TypeID
  13.  
  14.                 cmd.Parameters.Add("@First_Name", SqlDbType.VarChar)
  15.                 cmd.Parameters.Item("@First_Name").Value = First_Name
  16.  
  17.                 cmd.Parameters.Add("@Last_Name", SqlDbType.VarChar)
  18.                 cmd.Parameters.Item("@Last_Name").Value = Last_Name
  19.  
  20.                 cmd.Parameters.Add("@Date_Birth", SqlDbType.DateTime)
  21.                 cmd.Parameters.Item("@Date_Birth").Value = Date_Birth
  22.  
  23.                 cmd.Parameters.Add("@Citizenship", SqlDbType.VarChar)
  24.                 cmd.Parameters.Item("@Citizenship").Value = Citizenship
  25.  
  26.                 cmd.Parameters.Add("@Civil_Id", SqlDbType.Int)
  27.                 cmd.Parameters.Item("@Civil_Id").Value = Civil_Id
  28.  
  29.                 cmd.Parameters.Add("@Address", SqlDbType.VarChar)
  30.                 cmd.Parameters.Item("@Address").Value = address
  31.  
  32.                 cmd.Parameters.Add("@Father_Name", SqlDbType.VarChar)
  33.                 cmd.Parameters.Item("@Father_Name").Value = Father_Name
  34.  
  35.                 cmd.Parameters.Add("@Profession", SqlDbType.VarChar)
  36.                 cmd.Parameters.Item("@Profession").Value = Profession
  37.  
  38.                 cmd.Parameters.Add("@phoneNo", SqlDbType.VarChar)
  39.                 cmd.Parameters.Item("@phoneNo").Value = phoneNo
  40.  
  41.                 cmd.Parameters.Add("@emailid", SqlDbType.VarChar)
  42.                 cmd.Parameters.Item("@emailid").Value = emailid
  43.  
  44.                 cmd.Parameters.Add("@Ext", SqlDbType.VarChar)
  45.                 cmd.Parameters.Item("@Ext").Value = ext
  46.  
  47.                 cmd.Parameters.Add("@Description", SqlDbType.VarChar)
  48.                 cmd.Parameters.Item("@Description").Value = Description
  49.  
  50.                 cmd.Parameters.Add("@Date_creation", SqlDbType.DateTime)
  51.                 cmd.Parameters.Item("@Date_creation").Value = Date.Now
  52.  
  53.                 cmd.Parameters.Add("@CreatedBy", SqlDbType.VarChar)
  54.                 cmd.Parameters.Item("@CreatedBy").Value = CreatedBy
  55.  
  56.                 cmd.Parameters.Add("@UserID", SqlDbType.VarChar)
  57.                 cmd.Parameters.Item("@UserID").Value = UserID
  58.  
  59.                 cmd.CommandType = CommandType.StoredProcedure
  60.                 cmd.CommandText = "Execute_Account2"
  61.  
  62.                 Dim QueryExecute As New DatabaseConnection.DataBaseConnaction.ConnectionClass
  63.                 QueryExecute.ExecuteNonquery(cmd)
  64.                 Return "New Account has been successully added"
  65.             Catch ex As Exception
  66.  
  67.                 Return "Error"
  68.  
  69.             End Try
  70.         End Function
  71.  
  72.     End Class
  73.  
  74. End Namespace
  75.  

I am geeting the Error pls any one sole this
Nov 6 '08 #1
Share this Question
Share on Google+
4 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
Next time....

1. Please use code tags.
2. Please post questions in their appropriate forum, and not the introductions forum.

Regards,

Jeff
Moderator
Nov 6 '08 #2

P: 6
ALTER PROCEDURE [dbo].[InsertAccount]

@BankID AS VARCHAR(500) ,
@Account_TypeID AS VARCHAR(500) ,
@First_Name AS VARCHAR(500) ,
@Last_Name AS VARCHAR(500) ,
@Date_Birth AS DATETIME ,
@Citizenship AS VARCHAR(500) ,
@Civil_Id AS BIGINT ,
@Address AS VARCHAR(500) ,
@Father_Name AS VARCHAR(500) ,
@Profession AS VARCHAR(500) ,
@phoneNo varchar(500) ,
@emailid varchar(500) ,
@Ext varchar(50) ,
@Description AS VARCHAR(500) ,
@Date_creation AS DATETIME ,
@CreatedBy AS VARCHAR(500) ,
@UserID AS VARCHAR(500)


AS
BEGIN

------------Account Number genaration-----------
DECLARE @Account_Number AS VARCHAR(500) ;
-- DECLARE @AccountTypeID AS VARCHAR(500) ;
---- SELECT @Location=BankLocation FROM Bank WHERE BankID=@BankID
---- SELECT @AccountTypeID=AccountTypeID FROM AccountTypes WHERE AccountTypeID=@Account_TypeID
IF @Account_TypeID='SB'
BEGIN
IF @BankID='NBKFAR01'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '101' AND '75000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=101
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE IF @BankID='NBKMIR01'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '75001' AND '150000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=75001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE IF @BankID='NBKSRK01'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '150001' AND '225000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=150001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE IF @BankID='NBKSRK02'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '225001' AND '300000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=225001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE
BEGIN
RAISERROR('Invalid Information',18,3)
END
END
ELSE IF @Account_TypeID='AC'
BEGIN
IF @BankID='NBKFAR01'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '2000001' AND '2075000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=2000001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE IF @BankID='NBKMIR01'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '2075001' AND '2150000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=2075001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE IF @BankID='NBKSRK01'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '2150001' AND '2225000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=2150001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE IF @BankID='NBKSRK02'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '2225001' AND '2300000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=2225001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE
BEGIN
RAISERROR('Invalid Information',18,3)
END
END
ELSE IF @Account_TypeID='FIX'
BEGIN
IF @BankID='NBKFAR01'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '5000001' AND '5075000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=5000001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE IF @BankID='NBKMIR01'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '5075001' AND '5150000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=5075001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE IF @BankID='NBKSRK01'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '5150001' AND '5225000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=5150001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE IF @BankID='NBKSRK02'
BEGIN
SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '5225001' AND '5300000'
IF @Account_Number IS NULL
BEGIN
SELECT @Account_Number=5225001
END
ELSE
BEGIN
SELECT @Account_Number=@Account_Number+1
END
END
ELSE
BEGIN
RAISERROR('Invalid Information',18,3)
END
END


INSERT INTO AccountDetails
(
Account_Number ,
BankID ,
Account_TypeID ,
First_Name ,
Last_Name ,
Date_Birth ,
Citizenship ,
Civil_Id ,
Address ,
Father_Name ,
Profession ,
Date_creation ,
phoneNo ,
emailid ,
Ext ,
Description ,
CreatedBy ,
UserID

)
VALUES
(
@Account_Number ,
@BankID ,
@Account_TypeID ,
@First_Name ,
@Last_Name ,
@Date_Birth ,
@Citizenship ,
@Civil_Id ,
@Address ,
@Father_Name ,
@Profession ,
@Date_creation ,
@phoneNo ,
@emailid ,
@Ext ,
@Description ,
@CreatedBy ,
@UserID
)


END

Dear All
i'm using this code to insert a record, but wen i'm using wrong data that time i'm not able to retrivew Error msg please replay me.
nazim
Dec 31 '08 #3

P: 6
  1. ALTER PROCEDURE [dbo].[InsertAccount]

    @BankID AS VARCHAR(500) ,
    @Account_TypeID AS VARCHAR(500) ,
    @First_Name AS VARCHAR(500) ,
    @Last_Name AS VARCHAR(500) ,
    @Date_Birth AS DATETIME ,
    @Citizenship AS VARCHAR(500) ,
    @Civil_Id AS BIGINT ,
    @Address AS VARCHAR(500) ,
    @Father_Name AS VARCHAR(500) ,
    @Profession AS VARCHAR(500) ,
    @phoneNo varchar(500) ,
    @emailid varchar(500) ,
    @Ext varchar(50) ,
    @Description AS VARCHAR(500) ,
    @Date_creation AS DATETIME ,
    @CreatedBy AS VARCHAR(500) ,
    @UserID AS VARCHAR(500)


    AS
    BEGIN

    ------------Account Number genaration-----------
    DECLARE @Account_Number AS VARCHAR(500) ;
    -- DECLARE @AccountTypeID AS VARCHAR(500) ;
    ---- SELECT @Location=BankLocation FROM Bank WHERE BankID=@BankID
    ---- SELECT @AccountTypeID=AccountTypeID FROM AccountTypes WHERE AccountTypeID=@Account_TypeID
    IF @Account_TypeID='SB'
    BEGIN
    IF @BankID='NBKFAR01'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '101' AND '75000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=101
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE IF @BankID='NBKMIR01'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '75001' AND '150000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=75001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE IF @BankID='NBKSRK01'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '150001' AND '225000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=150001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE IF @BankID='NBKSRK02'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '225001' AND '300000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=225001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE
    BEGIN
    RAISERROR('Invalid Information',18,3)
    END
    END
    ELSE IF @Account_TypeID='AC'
    BEGIN
    IF @BankID='NBKFAR01'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '2000001' AND '2075000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=2000001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE IF @BankID='NBKMIR01'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '2075001' AND '2150000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=2075001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE IF @BankID='NBKSRK01'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '2150001' AND '2225000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=2150001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE IF @BankID='NBKSRK02'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '2225001' AND '2300000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=2225001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE
    BEGIN
    RAISERROR('Invalid Information',18,3)
    END
    END
    ELSE IF @Account_TypeID='FIX'
    BEGIN
    IF @BankID='NBKFAR01'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '5000001' AND '5075000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=5000001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE IF @BankID='NBKMIR01'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '5075001' AND '5150000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=5075001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE IF @BankID='NBKSRK01'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '5150001' AND '5225000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=5150001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE IF @BankID='NBKSRK02'
    BEGIN
    SELECT @Account_Number=MAX(Account_Number) FROM AccountDetails WHERE Account_Number BETWEEN '5225001' AND '5300000'
    IF @Account_Number IS NULL
    BEGIN
    SELECT @Account_Number=5225001
    END
    ELSE
    BEGIN
    SELECT @Account_Number=@Account_Number+1
    END
    END
    ELSE
    BEGIN
    RAISERROR('Invalid Information',18,3)
    END
    END


    INSERT INTO AccountDetails
    (
    Account_Number ,
    BankID ,
    Account_TypeID ,
    First_Name ,
    Last_Name ,
    Date_Birth ,
    Citizenship ,
    Civil_Id ,
    Address ,
    Father_Name ,
    Profession ,
    Date_creation ,
    phoneNo ,
    emailid ,
    Ext ,
    Description ,
    CreatedBy ,
    UserID

    )
    VALUES
    (
    @Account_Number ,
    @BankID ,
    @Account_TypeID ,
    @First_Name ,
    @Last_Name ,
    @Date_Birth ,
    @Citizenship ,
    @Civil_Id ,
    @Address ,
    @Father_Name ,
    @Profession ,
    @Date_creation ,
    @phoneNo ,
    @emailid ,
    @Ext ,
    @Description ,
    @CreatedBy ,
    @UserID
    )


    END

    Dear All
    i'm using this code to insert a record, but wen i'm using wrong data that time i'm not able to retrivew Error msg please replay me.
    nazim[/quote]
Dec 31 '08 #4

P: 6
i'm not able to retriew Error mg
@nazimsal
Dec 31 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.