Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
7
Reply
c# read last record from database error
Umut çelik
Apr 14 2016 3:37 AM
321
Reply
I can not find fault.please help me
Additional information:
Object reference not set to an instance of an object
-----------------------------------------------
public static ENOTLAR Select(ENOTLAR item)
{
try
{
SqlCommand com = new SqlCommand("NOTLAR_SonKayit", Baglanti.Con);
com.CommandType = CommandType.StoredProcedure;
if (com.Connection.State != ConnectionState.Open)
{
com.Connection.Open();
}
com.Parameters.AddWithValue("ID", item.ID);
SqlDataReader rdr = com.ExecuteReader();
while (rdr.Read())
{
item = new ENOTLAR();
item.ID = Convert.ToInt32(rdr["ID"]);
item.KONU = rdr["KONU"].ToString();
item.TARIH = Convert.ToDateTime(rdr["TARIH"]);
item.YAZI = rdr["YAZI"].ToString();
}
rdr.Close();
}
catch
{
item = null;
}
return item;
}
-------------- ---------------
private void LastNot()
{
ENOTLAR not = new ENOTLAR();
BLLNOTLAR.Skayit(not);
toolStripLabel3.Text = not.YAZI.ToString();
}
--------------------------
sql procedure
NOTLAR_SonKayit
CREATE PROC NOTLAR_SonKayit
AS
SELECT TOP 1 YAZI FROM NOTLAR
ORDER BY ID DESC;
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
7
)
Next Recommended Forum
MVC
how to save extracted data in xml file