TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Umut çelik
NA
33
10.2k
c# read last record from database error
Apr 14 2016 3:37 AM
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;
Reply
Answers (
7
)
MVC
how to save extracted data in xml file