Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hello,
this is my code

VB
con = New SqlConnection("Data Source=LOCALhost;Initial Catalog=InwardOutwardSystem;Integrated Security=True")
        con.Open()
        Dim T As String
        Dim x As String
        x = "select LoginId from UserMaster"
        
        If CBFrom.Text = x Then
            T = "insert into TransactionMaster(TransactionType)values=('Inward') "
        Else
            T = "insert into TransactionMaster(TransactionType)values('OutsideInward')"
        End If
        cmd = New SqlCommand(T, con)
        DR = cmd.ExecuteReader(CommandBehavior.CloseConnection)

In this
UserMaster is a Table in that LoginId field the employes name is resigter already

and i want to check that "CBFrom.Text" this is my application From TextBox name.
in if condition i m check the TextBox value is match with the UserMaster Table value or not.
if it will be matched then execute the 1st statement
otherwise execute the else statement.
But bt not work.
plz tell me what is wrong in this.
Posted
Updated 8-Jul-12 7:20am
v2

1 solution

try

VB
If CBFrom.Text = x Then
  T = "insert into TransactionMaster (TransactionType) values ('Inward')"
Else
  T = "insert into TransactionMaster (TransactionType) values('OutsideInward')"
End If


since this is insert queary you can call SqlCommand.ExecuteNonQuery method.
C#
cmd.ExecuteNonQuery(CommandBehavior.CloseConnection)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900