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
ahmed salah
NA
85
58.8k
object reference not set to an instance of object c#
Apr 27 2017 11:00 AM
I work in windows form c# vs 2015 i get error i need to solve it
but i dont know how to solve it
i write function in textbox changed event but when i start writing in textbox
get error object reference not set to an instance of object .
so that why this problem happen and how to solve it .
in textbox changed event
private
void
textBox3_TextChanged(
object
sender, EventArgs e)
{
try
{
MatrixClass matrix =
new
MatrixClass();
string
value1 = matrix.GetAtcCode(textBox3.Text);
textBox1.Text = value1;
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public
string
GetAtcCode(
string
GenericName)
{
SqlConnection con =
new
SqlConnection(connection);
con.Open();
SqlCommand comm =
new
SqlCommand(
"ATC_Code_ByGeneric_H"
, con);
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.Add(
new
SqlParameter(
"@Lvl_Name"
, GenericName));
string
ret = comm.ExecuteScalar().ToString();
con.Close();
return
ret;
}
stored procedure
ALTER PROCEDURE [dbo].[ATC_Code_ByGeneric_H]
@Lvl_Name nvarchar(500)
AS
SELECT Tbl_Lvl1.Code + Tbl_Lvl2.Code + Tbl_Lvl3.Code + Tbl_Lvl4.Code + Tbl_Lvl5.Code AS ATC_Code
FROM Tbl_Lvl1
INNER JOIN
Tbl_Lvl2
ON Tbl_Lvl1.S_ID = Tbl_Lvl2.UpLvl_ID
INNER JOIN
Tbl_Lvl3
ON Tbl_Lvl2.S_ID = Tbl_Lvl3.UpLvl_ID
INNER JOIN
Tbl_Lvl4
ON Tbl_Lvl3.S_ID = Tbl_Lvl4.UpLvl_ID
INNER JOIN
Tbl_Lvl5
ON Tbl_Lvl4.S_ID = Tbl_Lvl5.UpLvl_ID
WHERE (Tbl_Lvl5.Lvl_Name = @Lvl_Name) and Tbl_Lvl5.human=1
RETURN
Reply
Answers (
4
)
How To Disable maximizing window double click on title bar
C# code and iTextSharp report problem on column size