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 7854933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:14:20+00:00 2026-06-02T20:14:20+00:00

Here is a background on my program: each protein is made from a sequence

  • 0

Here is a background on my program: each protein is made from a sequence of amino acids(or AA)

I have some tables :tblProInfo(that contains general info about proteins),tblOrderAA(that contains the sequence(AA sequence) of specific protein(for each protein there is a serial number that i set before))

now, I’m trying to retvive the science names of the protein that contains part of sequence that the user put in textbox1. It is likely that more than one protein contains the sequence that the user typed.

Here is my code. I got “Syntax error” and I’m sure I have more mistakes.Please HELP me!

        public void OpenDB()
    {
        dataConnection = new OleDbConnection();
        try
        {
            dataConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Projects_2012\\Project_Noam\\Access\\myProject.accdb";
            dataConnection.Open();
        }
        catch (Exception e)
        {
            MessageBox.Show("Error accessing the database: " +
                             e.Message,
                             "Errors",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
        }
    }

private string FromCodonsToProtein(string codons)
    {
        OpenDB();
        int sizePro=0, i,counter=0,serialPro;
        string st="",tempst="";

        OleDbCommand datacommand = new OleDbCommand();
        datacommand.Connection = dataConnection;
        datacommand.CommandText = "SELECT tblProInfo.proInfoAAnum, tblProInfo.proInfoSerialNum,tblProInfo.proInfoScienceName FROM tblProInfo";
        OleDbDataReader dataReader = datacommand.ExecuteReader();
        while(dataReader.Read())
        {
            sizePro = dataReader.GetInt32(counter);
            serialPro= dataReader.GetInt32(counter+1);
            counter++;
              OleDbCommand cmd= new OleDbCommand();
              cmd.Connection = dataConnection;
              cmd.CommandText = "SELECT tblOrderAA.orderAACodon1 FROM tblOrderAA"
                               +"WHERE (((tblOrderAA.orderAASerialPro)='"+serialPro+"'))";

              OleDbDataReader rdr = cmd.ExecuteReader();
            tempst="";
            for (i = 0; i > sizePro; i++)
            {
                tempst = tempst + rdr.GetString(i);
            }
            if (tempst.Contains(codons))
            {
                st = st + " \n" + dataReader.GetString(counter);
            }
        }
            return st;


    }
  • 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-06-02T20:14:21+00:00Added an answer on June 2, 2026 at 8:14 pm

    Missing a space here

        cmd.CommandText = "SELECT tblOrderAA.orderAACodon1 FROM tblOrderAA" 
                           +"WHERE (((tblOrderAA.orderAASerialPro)='"+serialPro+"'))"; 
    

    rewrite in this way

        cmd.CommandText = "SELECT tblOrderAA.orderAACodon1 FROM tblOrderAA"  
                           +" WHERE (((tblOrderAA.orderAASerialPro)='"+serialPro+"'))"; 
                          // ^ here 
    

    However you should use parametrized query (also with msaccess) to avoid possible errors and injection attacks.
    Another problem is the global dataConnection. Don’t do that, you gain nothing in this way.
    Return the connection and encapsulate it with a using statement.

    For example:

    public OleDbConnection OpenDB()   
    {   
        dataConnection = new OleDbConnection();   
        dataConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Projects_2012\\Project_Noam\\Access\\myProject.accdb";   
        dataConnection.Open();   
        return dataConnection;
    }
    

    then in the calling code use this syntax

    using(OleDbConnection cnn = OpenDB())
    {
        // in the rest of your code, replace dataConnection with cnn
        // The using statement will ensure that in the case of exceptions
        // your connection will be allways closed and properly disposed
    
        ........
    
    }
    

    EDIT: Can’t give you a full working solutions, too many aspects of your problem are unknown to me, however a great simplification will be to change your query in this way

    SELECT DISTINCT 
           tblProInfo.proInfoAAnum, 
           tblProInfo.proInfoSerialNum,
           tblProInfo.proInfoScienceName 
    FROM   tblProInfo LEFT JOIN tblOrderAA 
      ON   tblOrderAA.orderAASerialPro = tblProInfo.proInfoSerialNum
    
    WHERE  tblOrderAA.orderAACodon1 = @codons
    

    Try it directly in access using its query editor, if it works as you expected then change your code. You don’t need two query and crossed loops to get the results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok.. here is some background on the issue. I have some 'critical' code that
Background I have a program that has implemented the two classic taxes for Ontario
Here's the quick background: I've got a client and a server program that are
All, Need some help here. I am from a purely Java background and don't
Here's some background on my program: [self.channels ] is an array of Channel objects.
I have googled an serached a lot here about background runnin aps but have
I have an Ul of item. I want to alternate there background color here
Here's my regex code: preg_match_all('/background[-image]*:[\s]*url\([|\']+(.*)[|\']+\)/', $css, $matches, PREG_SET_ORDER); It looks for CSS that looks
Here is the situation: You have one long-running calculation running in a background thread.
I currently have a complete cover background image. Here is the code: #back{ /*

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.