I am designing a web page, i want to get last entry from the column ("call_id) from the table "tbl_CALL" and store in the variable("lastcallId"). can anyone help me for writing he code in c#. Thanks in advance
user2042360
问问题
53 次
2 回答
0
There are a lot of questions here such as which technology are you using in C# (ADO.net, Entity Framework, NHibernate, etc.)? Also, it is not clear if the call_id column is asending order. Assuming the key is auto generated and is always ascending, you could write an SQL statement like the following to get the max out.
SELECT MAX(call_id) as "last_call_id" FROM mytable;
Without knowing which technology you are using, it is hard to help more.
于 2013-02-17T06:01:43.767 回答
0
Try this: on your web.config:
<connectionStrings>
<add name="OracleDBConnString" connectionString="Provider=MSDAORA;Data Source=[database];User ID=[userID];Password=[yourPassword];"
providerName="System.Data.OleDB" />
</connectionStrings>
in your C#:
private OleDbConnection conn = new OleDbConnection();
private string _strCon = ConfigurationManager.ConnectionStrings["OracleDBConnString"].ConnectionString;
private OleDbTransaction _trans = null;
DataTable dt = new DataTable();
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter();
conn.Open();
strSelectQuery = "SELECT last(call_no) FROM tbl_IThelpdesk"; // here you have to put your query
da.SelectCommand = new OleDbCommand(strSelectQuery, conn);
da.Fill(ds);
dt = ds.Tables[0];
conn.Close();
Now, the content of your SQL query is now at dt
. I hope this helps.
于 2013-02-17T06:38:53.873 回答