Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below mention my code
I want to generate number against each TransmittleNo which is already exist in table called T_doc_Control.
C#
query = "Select Distinct TransmittleNo as TransNo from Temp_Doc Order By TransmittleNo";
                   ds = null;
                   ds = con.get_records(query);
                   if (ds.Tables[0].Rows.Count > 0)
                   {
                       for (int inti = 0; inti < ds.Tables[0].Rows.Count; inti++)
                       {
                       strTransmittleNo = ds.Tables[0].Rows[0]["TransNo"].ToString();
                       //strTransmittleSeq = "0";
                       strPentaTransmittleNo = "";

                       query = "Select decode(max(TransmittleSeq)+1,null,1,max(TransmittleSeq)+1) as TransSeqNo from T_Doc_Control Where TransmittleNo = '" + strTransmittleNo + "' And TransmittleDate = '" + strIssueDate.Trim()  + "' And TransmittleSeq is not null"; // +strTransmittleNo + "'";
                       dsGrid = null;
                       dsGrid = con.get_records(query);
                       if (dsGrid.Tables[0].Rows.Count > 0)
                       {
                           strPentaTransmittleNo = "PGM-TransmittleNo-" + dsGrid.Tables[0].Rows[0]["TransSeqNo"].ToString();
                           strTransmittleSeq = dsGrid.Tables[0].Rows[0]["TransSeqNo"].ToString();
                       }

                       query = "Update T_DOC_Control set PentaTransmittleNo = '" + strPentaTransmittleNo + "',";
                       query = query + "TransmittleSeq = " + strTransmittleSeq + " ";
                       query = query + "Where TransmittleNo = '" + strTransmittleNo + "' And PentaTransmittleNo IS NULL";
                       intResult = con.insert_records(query);
                       }
                   }

suggest me please !!
Posted
Comments
[no name] 16-Apr-14 8:00am    
Suggest what? First thing to do would be to rewrite your queries and get rid of all of this SQL injection attack waiting to happen code. Then re-edit your question to include your input and expect output.
Daljit S. Gill 16-Apr-14 8:24am    
This code generating auto number in series against each row.
like this
TransmittleNo PentaTransmittleNo

XX01 PMG01
YY01 PMG02
ZZ01 PMG03
XX01 PMG04

My Expected Output is
TransmittleNo PentaTransmittleNo

XX01 PMG01
YY01 PMG02
ZZ01 PMG03
XX01 PMG01

I want PentaTransmittleNo generate Group by TransmittleNo
rajivsharma 16-Apr-14 8:06am    
Can you elaborate your question , its not clear. Instead of putting the code here better if you can put very small example.
Tell us what is your expected output.
first thing which you need to do is remove this inline query from the source code and create some SP in sql server.
Daljit S. Gill 16-Apr-14 8:23am    
This code generating auto number in series against each row.
like this
TransmittleNo PentaTransmittleNo

XX01 PMG01
YY01 PMG02
ZZ01 PMG03
XX01 PMG04

My Expected Output is
TransmittleNo PentaTransmittleNo

XX01 PMG01
YY01 PMG02
ZZ01 PMG03
XX01 PMG01

I want PentaTransmittleNo generate Group by TransmittleNo

1 solution

to auto generate numbers from database you can use this query
SQL
SELECT TOP 1 ChargebyMonth FROM tblsociety
ORDER BY NEWID()


and call result buy your app
 
Share this answer
 

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



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