Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6067533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:37:05+00:00 2026-05-23T09:37:05+00:00

I have two tables one is members table with columns member id , member

  • 0

I have two tables one is members table with columns member id , member first name, member last name. I have another table guest passes with columns guest pass id and member id and issue date .

I have a list view that will displays guest passes details (I.e) like member name and issue date and I have two text boxes those are for entering member name and issue date .

member name text box is auto complete text box that working fine….

but the problem is when I am entering the name that is not in member table at this time it will accept and displays a blank field in list view in member name column and member id is stored as “0” in guest pass table ……

I don’t want to display the member name empty blank and I don t want to store “0” in guest pass table

and this is the insert statement

          sql2 = @"INSERT INTO guestpasses(member_Id,guestPass_IssueDate)";
          sql2 += " VALUES(";
          sql2 += "'" + tbCGuestPassesMemberId.Text + "'";
          sql2 += ",'" + tbIssueDate.Text + "'";

guestpassmemberId = memberid

is there any validation that need to be done

and this is the auto complete text box statement

           sql = @"SELECT member_Id FROM members WHERE  concat(member_Firstname,'',member_Lastname) ='" + tbMemberName.Text+"'";

 dt = GetData(sql, mf);

         if (dt != null)
         {
            if (dt.Rows.Count > 0)
            {
                tbCGuestPassesMemberId.Text  = Convert.ToInt32(dt.Rows[0]  ["member_Id"]).ToString();
            }
         }

can any one help me on this …
is there any type of validation with sql query

pls help me …..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:37:06+00:00Added an answer on May 23, 2026 at 9:37 am

    You can validate the values before passing them to the INSERT. Additionally you can also set a constraint to validate versus a regular expression in SQL.

    SQL constraints

    To validate before inserting you should have something like this:

      private void validateData(Long memberId) {
           //Pseudo code Depends on how you are connecting to your database...
           SQLQuery query = getQuery("existsMemberId");
           query.setParameter("memberId");
           executeQuery(query);
           // If the query returns something then the reference exists and it is ok to proceed
      }
    

    In the file you are storing your queries…

       #existsMemberId
       select 1
       from members mem
       where mem.id = :id <-- parameter
    

    Additionally you should make foreign key constraint between members and guest passes with ID as the foreign key:

       ALTER TABLE GuestPasses
       ADD CONSTRAINT fk_memberId
       FOREIGN KEY (id)
       REFERENCES Members(id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables. One changelog-table, the details of which aren't important here. Another
I have two parent tables, BusinessGroup and SocialGroup, and one child table, Members. A
I have two tables : one table it matchs and the other is teams.
I have two tables, one Company and one Employee: class Company(models.Model): name = models.CharField(max_length=60)
I have two tables in a database. One is for a member and one
I have two tables. One table is meant to serve as a transaction history
I have two tables one has a three column composite key. The other needs
I have two tables, one is products and one salesRecords I am using this
I have two tables, one that contains volunteers, and one that contains venues. Volunteers
I have two tables, one stores the products and quantity we have bought, the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.