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
Isidro Padilla
1.4k
319
19.5k
Why doesn’t this method work?
Apr 19 2020 11:59 AM
I am continuing with my SMO learning and again I am blocked.
Something is missing in this method that I am not able to see.
The view I have previously created it without problems, but when I try creating the delete method sends me the following message:
Reference or object Not instantiated to an object.
I hope a charitable soul lends me a hand.
private
void
BtnBorrarVista_Click(
object
sender, EventArgs e)
{
try
{
if
(MessageBox.Show(
"Está intentando borrar la Vista "
+ textBoxBorrarVista.Text +
" ¿Está seguro de que quiere eliminarla?"
,
"¡Atención!"
, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
m_Server =
new
Server(cmbServerName.Text);
Database myNewDatabase = m_Server.Databases[cmbDbName.Text];
Microsoft.SqlServer.Management.Smo.View view = myNewDatabase.Views[textBoxBorrarVista.Text];
view.Drop();
MessageBox.Show(
"La Vista "
+ textBoxBorrarVista.Text +
" se borró con éxito"
);
}
else
{
MessageBox.Show(
"Operación abortada. La Vista "
+ textBoxBorrarVista.Text +
" no se ha borrado"
);
}
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
Reply
Answers (
10
)
Extracting data from a pdf file with c#
how to count total folder count from website folder