|
-
Nov 7th, 2007, 08:52 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Argument 'Prompt' cannot be converted to type 'String'.
Im getting this exception when trying to create a database using an sql script...
sql script:
Code:
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'DBTest2')
DROP DATABASE [DBTest2]
CREATE DATABASE [DBTest2]
exec sp_dboption N'DBTest2', N'autoclose', N'true'
exec sp_dboption N'DBTest2', N'bulkcopy', N'false'
exec sp_dboption N'DBTest2', N'trunc. log', N'true'
exec sp_dboption N'DBTest2', N'torn page detection', N'true'
exec sp_dboption N'DBTest2', N'read only', N'false'
exec sp_dboption N'DBTest2', N'dbo use', N'false'
exec sp_dboption N'DBTest2', N'single', N'false'
exec sp_dboption N'DBTest2', N'autoshrink', N'true'
exec sp_dboption N'DBTest2', N'ANSI null default', N'false'
exec sp_dboption N'DBTest2', N'recursive triggers', N'false'
exec sp_dboption N'DBTest2', N'ANSI nulls', N'false'
exec sp_dboption N'DBTest2', N'concat null yields null', N'false'
exec sp_dboption N'DBTest2', N'cursor close on commit', N'false'
exec sp_dboption N'DBTest2', N'default to local cursor', N'false'
exec sp_dboption N'DBTest2', N'quoted identifier', N'false'
exec sp_dboption N'DBTest2', N'ANSI warnings', N'false'
exec sp_dboption N'DBTest2', N'auto create statistics', N'true'
exec sp_dboption N'DBTest2', N'auto update statistics', N'true'
use [DBTest2]
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_HRM_AreaTematica_HRM_AreaEducForm]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[HRM_AreaTematica] DROP CONSTRAINT FK_HRM_AreaTematica_HRM_AreaEducForm
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_HRM_AreaEducForm_HRM_AreaEstudo]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[HRM_AreaEducForm] DROP CONSTRAINT FK_HRM_AreaEducForm_HRM_AreaEstudo
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[HRM_Apetrechamento]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[HRM_Apetrechamento]
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[HRM_AreaEducForm]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[HRM_AreaEducForm]
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[HRM_AreaEstudo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[HRM_AreaEstudo]
CREATE TABLE [dbo].[HRM_Apetrechamento] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[ref] [varchar] (50) COLLATE Latin1_General_CI_AS NOT NULL ,
[ref_id] [int] NOT NULL ,
[designacao] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,
[quantidade] [int] NULL ,
[observacoes] [varchar] (250) COLLATE Latin1_General_CI_AS NULL
) ON [PRIMARY]
CREATE TABLE [dbo].[HRM_AreaEducForm] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[codigo] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[designacao] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[areaestudo_id] [int] NOT NULL
) ON [PRIMARY]
CREATE TABLE [dbo].[HRM_AreaEstudo] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[codigo] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[designacao] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[grgrupo_id] [int] NOT NULL
) ON [PRIMARY]
ALTER TABLE [dbo].[HRM_Apetrechamento] WITH NOCHECK ADD
CONSTRAINT [PK_HRM_Apetrechamento] PRIMARY KEY CLUSTERED
(
[id]
) ON [PRIMARY]
ALTER TABLE [dbo].[HRM_AreaEducForm] WITH NOCHECK ADD
CONSTRAINT [PK_HRM_AreaEducForm] PRIMARY KEY CLUSTERED
(
[id]
) ON [PRIMARY]
ALTER TABLE [dbo].[HRM_AreaEstudo] WITH NOCHECK ADD
CONSTRAINT [PK_HRM_AreaEstudo] PRIMARY KEY CLUSTERED
(
[id]
) ON [PRIMARY]
ALTER TABLE [dbo].[HRM_AreaEducForm] ADD
CONSTRAINT [FK_HRM_AreaEducForm_HRM_AreaEstudo] FOREIGN KEY
(
[areaestudo_id]
) REFERENCES [dbo].[HRM_AreaEstudo] (
[id]
)
ALTER TABLE [dbo].[HRM_AreaEstudo] ADD
CONSTRAINT [FK_HRM_AreaEstudo_HRM_GrGrupos] FOREIGN KEY
(
[grgrupo_id]
) REFERENCES [dbo].[HRM_GrGrupos] (
[id]
)
vb code:
Code:
Private Sub CreateDB(ByVal value As String)
Dim objCommand As New SqlClient.SqlCommand()
With objCommand
.Connection = _objDataFactory.Connection
.CommandText = value
.CommandType = CommandType.Text
Try
.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex)
Exit Sub
End Try
End With
MsgBox("Completed with no errors.")
End Sub
Any clue?
-
Nov 7th, 2007, 09:09 AM
#2
Fanatic Member
Re: Argument 'Prompt' cannot be converted to type 'String'.
Try this:
Tenta isto:
vb Code:
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
-
Nov 7th, 2007, 09:10 AM
#3
Re: Argument 'Prompt' cannot be converted to type 'String'.
Where does it fail? What line.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Nov 7th, 2007, 09:18 AM
#4
Thread Starter
Frenzied Member
Re: Argument 'Prompt' cannot be converted to type 'String'.
 Originally Posted by Lasering
Try this:
Tenta isto:
vb Code:
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try

this is the exception details:
Code:
System.ArgumentException was unhandled
Message="Argument 'Prompt' cannot be converted to type 'String'."
Source="Microsoft.VisualBasic"
StackTrace:
at Microsoft.VisualBasic.Interaction.MsgBox(Object Prompt, MsgBoxStyle Buttons, Object Title)
at HRM.Admin.CreateTables(String value) in F:\Workspace\src\HRM\Forms\Global\Admin.vb:line 63
at HRM.Admin.cmdCreateDB_Click(Object sender, EventArgs e) in F:\Workspace\src\HRM\Forms\Global\Admin.vb:line 45
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at HRM.Main.mnuAdministrador_Click(Object sender, EventArgs e) in F:\Workspace\src\HRM\Forms\Global\Main.vb:line 1286
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at HRM.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
-
Nov 7th, 2007, 09:19 AM
#5
Thread Starter
Frenzied Member
Re: Argument 'Prompt' cannot be converted to type 'String'.
 Originally Posted by GaryMazzone
Where does it fail? What line.
dont know... perhaps some character in the script...
-
Nov 7th, 2007, 09:26 AM
#6
Fanatic Member
Re: Argument 'Prompt' cannot be converted to type 'String'.
As it says
at Microsoft.VisualBasic.Interaction.MsgBox(Object Prompt, MsgBoxStyle Buttons, Object Title)
try to delete the line Msgbox(ex.Message), if still gives an error, then i cant help, if it gives no error, then u can try Msgbox(ex.Message.ToString).
-
Nov 7th, 2007, 09:29 AM
#7
Re: Argument 'Prompt' cannot be converted to type 'String'.
Can you run each part of the script in SQL Server managment Studio on its own? Run each line not the script as a whole and see where it errors
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Nov 7th, 2007, 09:40 AM
#8
Re: Argument 'Prompt' cannot be converted to type 'String'.
Aww man..... dude...
1) Use MEssageBox.Show... not msgbox...
2) change it to ex.ToString to get it to display....
Lastly, expand the catch like so:
Code:
Catch sqlEx as SQLException
Messagebox.Show sqlEx.ToStirng
Catch ex as Exception
MessageBox.Show ex.ToString
You'll get more meaningful messages that way.
-tg
-
Nov 7th, 2007, 09:52 AM
#9
Thread Starter
Frenzied Member
Re: Argument 'Prompt' cannot be converted to type 'String'.
 Originally Posted by techgnome
Aww man..... dude...
1) Use MEssageBox.Show... not msgbox...
2) change it to ex.ToString to get it to display....
Lastly, expand the catch like so:
Code:
Catch sqlEx as SQLException
Messagebox.Show sqlEx.ToStirng
Catch ex as Exception
MessageBox.Show ex.ToString
You'll get more meaningful messages that way.
-tg
"MEssageBox.Show" thats not the point... this is just a testing code...
i already figure out... i removed the GO statements... thats why im getting this errors... to solve this i must parse the script in statements and execute one at time...
thx...
-
Nov 8th, 2007, 11:14 AM
#10
Thread Starter
Frenzied Member
Re: Argument 'Prompt' cannot be converted to type 'String'.
Problem solved...
I managed to parse in different statments (split the query using the GO command) and execute one at each time...
working great...
http://blog.humanhrm.com/?p=55
(sorry, its in portuguese... )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|