Click here to Skip to main content
15,904,156 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,


I have an ASP.Net application that publish on IIS 7. In my application i have calculated an JobID based on database Transaction made before.


This Calculation Part not reflect on my aspx Textbox(txt_jobid). Sample code is below. Please Check it out.
I'm not getting any error or something. Textbox(txt_jobid) value not assign Properly. Even in database i found my records are saved.

Its working perfectly in Development Machine. But not works on SERVER MACHINE.

Database Connections are perfect. But its not working.

Please help me out...


Problem is inside this function.Its works Perfect on my Development Machine


C#
public void CalculateJOBID()
    {
        DataTable mdt = new DataTable();
        int jobid=0;
        string qry = "select id as id ,jobid as jid from Jobsheet where id = (select max(id) from Jobsheet where date='"+ DateTime.Now.Date +"')";
        mdt = SQLobj.SQL_Adapter(qry);

        if (mdt.Rows.Count == 0)
            txt_jobid.Text = "1";
        else
        {
            string jid = mdt.Rows[0]["jid"].ToString();
            jobid = Convert.ToInt32(jid);
            if (mdt.Rows.Count > 0)
            {
                jobid = jobid + 1;
                txt_jobid.Text = jobid.ToString();
            }
        }

    }
Posted
Updated 6-Nov-11 20:30pm
v4
Comments
Sergey Alexandrovich Kryukov 7-Nov-11 1:49am    
This is a forum for software developers. For a software developer, there is no "not working", there are precise issue reports. Can you make a code sample, a simple and manageable one?
--SA
J.Karthick 7-Nov-11 2:21am    
I have paste a piece of code to calculate JOBID. i would call this function on Page Load
[no name] 7-Nov-11 2:20am    
Have you used any third party controls like Telerik.
J.Karthick 7-Nov-11 2:21am    
No...
shashikanth 2011 7-Nov-11 2:22am    
You should ask the question very precise manner, wedidnt get what is your problem, what is not working means....?
is it showing any error messege pr is their any failure of connection.?
ask correct way

In place of your connection string
place connection string of server
then place break point in your code
debug the code and check where exactly you are getting the error.
 
Share this answer
 
If their is any failure in retreiving data from database then what is jobid...?
Use this code..
C#
public void CalculateJOBID()
    {
        DataTable mdt = new DataTable();
        int jobid=0;
        string qry = "select id as id ,jobid as jid from Jobsheet where id = (select max(id) from Jobsheet where date='"+ DateTime.Now.Date +"')";
        mdt = SQLobj.SQL_Adapter(qry);
 
        if (mdt.Rows.Count == 0)
             jobid=1;
        else
         {
            string jid = mdt.Rows[0]["jid"].ToString();
            jobid = Convert.ToInt32(jid);
            if (mdt.Rows.Count > 0)
            {
                jobid = jobid + 1;
            }
        }
       txt_jobid.Text = jobid.ToString();

 
    }
 
Share this answer
 
Comments
J.Karthick 7-Nov-11 2:36am    
My textbox always displays "1" from my Posted code. hence my code works good i think so
Problem is the DATE FORMAT not supported my server's date format...


Now i'm converting my date in sql default format.
like....

Convert(varchar,getdate(),101)
 
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