VB.NET - Backup database error

Asked By Joseph
30-Jan-11 09:40 PM
I'm  using visual studio .net 2003 and mssql 2000 as my DB server. I created a vb program that perform backup on my database and I put a message "Backup done." when it finished. My question is, why this message "Invalid oject name 'mytable'" appears when "Backup done." prompt?

Can anybody help me on this? please...
Here's my code below.

Thank you in advance egghead. More power.



        oCOM = oCNN.CreateCommand
        oCOM.CommandTimeout = 6000
        oCOM.CommandText = "use master "
        oCOM.ExecuteNonQuery()
        oCOM.CommandText = "Select name from sysdevices where name ='Back" + sDB + "'"
        oDR = oCOM.ExecuteReader()
        If oDR.Read Then
          oDR.Close()
          oCOM.CommandText = "exec sp_dropdevice 'Back" + sDB + "'"
          oCOM.ExecuteNonQuery()
        End If
        oDR.Close()
        If IO.File.Exists(txtFilename.Text.Trim) Then
          IO.File.Delete(txtFilename.Text.Trim)
        End If
        oCOM.CommandText = "EXEC sp_addumpdevice 'disk', 'Back" + sDB + "' , '" + txtFilename.Text.Trim + "'"
        oCOM.ExecuteNonQuery()
        oCOM.CommandText = "backup database [" + sDB + "]  to Back" + sDB + " with password='" + CorePassWord(GetServerDateTime()) + "'"
        oCOM.ExecuteNonQuery()
  If Len(txtFileCopy.Text) <> 0 Then
          MsgBox("Backup done!" & Chr(13) & "Click Ok to send backup copy to the client computer.", MsgBoxStyle.Information, "System Message")
        Else
          MsgBox("Backup done!", MsgBoxStyle.Information, "System Message")
        End If
  Danasegarane Arunachalam replied to Joseph
31-Jan-11 01:37 AM
How do you check your database backup is done.I doubt the backup is not correctly.
It says that it is looking for table namely mytable and it could it not found. Check sp_addumpdevice stored procedure for that table.
  div v replied to Joseph
31-Jan-11 03:55 AM
hi,
'mytable' table is not exists in that database thats y your getting this message
this message "Invalid oject name 'mytable'
  Joseph replied to Danasegarane Arunachalam
31-Jan-11 07:58 PM

 

Hi,

 

Thank you so for your quick reply.

 

My backup was present in my backup folder, thats how I check. And by the way,  this error will not show everytime I made back up on my database. Just seldom.

 

Okey, I will check the stored proc.

Again, thankz and god bless.

Create New Account
help
Stored Procedure VB.NET Can you give one example for Stored procedure in Front-End & Back-End Respectively? To Create Procedure Go to solution explorer expand database and from the stored Procedure , right click on it and choose new stored procedure ALTER PROCEDURE dbo.Insertion ( @f1 varchar , @f2 varchar , ) AS / * SET NOCOUNT ON * / insert into
SqlParameters to be assigned values< / param> / / / <param name = "dataRow"> The dataRow used to hold the stored procedure's parameter values< / param> private static void AssignParameterValues(SqlParameter[] commandParameters, DataRow dataRow) { if ((commandParameters = = null param> / / / <param name = "transaction"> A valid SqlTransaction, or 'null'< / param> / / / <param name = "commandType"> The CommandType (stored procedure, text, etc.)< / param> / / / <param name = "commandText"> The stored procedure name or T-SQL command< / param> / / / <param name = "commandParameters"> An array of SqlParameters to be mustCloseConnection = false; } / / Associate the connection with the command command.Connection = connection; / / Set the command text (stored procedure name or SQL statement) command.CommandText = commandText; / / If we were provided a transaction, assign it
stored procedure how to write stored procedure for insert the record in sqlserver without using of parameter. . . it is possible. . . . . . .tell me how to do. . . . . . . how to write stored procedure with out parameter hi, To insert the record you have to use an another table you need to use values in insert command. Like this you can create stored procedure for insert create procedure SPInsert( @ Name varchar (50), @Address varchar (100), @Email varchar (20), @Mobile
can any one explain how to open the already created stored procedure of a database Hi here is the syntax to view the stored procedure S yntax: • To view the definition of a stored procedure: sp_helptext procedure_name • To view the information about a stored procedure: sp_help procedure_name • To view the dependencies of the stored procedure: sp_depends procedure_name procedure_name Is the
stored proocedure Hi i had created one stored procedure , now i want to call the stored procedure in to my application, i got some errors while calling the stored procedure , please help me Hi, You can call stored procedure in such way. But still if you fell your code is correct then share