Link to home
Start Free TrialLog in
Avatar of Moti Mashiah
Moti MashiahFlag for Canada

asked on

C# with database

Hi Guys ,

I have built new application and I'm trying to query some tables and columns from the database see could below: and also screenshot of my issue

string conn = "Data Source=srv-db-02;Initial Catalog=rmsmasterdbtest;Persist Security Info=True;User ID=test;Password=masterB4";
            //string Query = "select * from rmsmasterdbtest.dbo.PurchaseOrder where ponumber= '" + combopo.Text + "' ;";
            string Query = "select d.PONumber, b.ItemLookupCode, a.SerialNumber, a.SerialNumber2, a.SerialNumber3"
            + "from rmsmasterdbtest.from dbo.Serial AS A" 
            + "inner join dbo.item AS B on b.id = a.ItemID"
            + "inner join dbo.PurchaseOrderEntry AS C on C.ItemID = b.ID"
            + "inner join dbo.PurchaseOrder AS D on D.ID = c.PurchaseOrderID"
            + "where ponumber= '" + combopo.Text + "';";


            SqlConnection Myconn = new SqlConnection(conn);
            SqlCommand cmdDataBase = new SqlCommand(Query, Myconn);
            SqlDataReader Reader;

            try
            {
                Myconn.Open();
                Reader = cmdDataBase.ExecuteReader();
                if (Reader.Read())
                {

                    string stime = Reader.GetDateTime(Reader.GetOrdinal("SerialNumber2")).ToString();
                    string sstatus = Reader.GetString(Reader.GetOrdinal("SerialNumber3"));
                    
                    txtdate.Text = stime;
                    txtstatus.Text = sstatus;

Open in new window

Capture.JPG
ASKER CERTIFIED SOLUTION
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Moti Mashiah

ASKER

OH No I feel sooo stupid LOL.

Thank you very much it works now.
Perfect!!
Oh dear, really the answer was from Paul Jackson, mine was just a preference.

I'm able to re-open this for you for a split of points, just ask.

btw: no need to feel silly, we have all done things like this, me all too often :)
Sorry guys I didn't pay attention I'm going to divide the point.

Thank you very much.
Please reopen the question
solved
Thanks!