Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Powershell, can't add Parameter to insert command (1 reply)

$
0
0
Hi,

It try to create an insert with Powershell, and i have this error :

New-Object : Cannot find an overload for "MySqlParameter" and the argument count: "4".

Here is a part of my code :


$cmd = New-Object Mysql.Data.MysqlClient.MySqlCommand( "SELECT SERVER,INSTANCE,BASE,TAG,DESCRIPTION,DATESTART,DATEEND,TYPE,SIZE,COMPRESSED_SIZE FROM SQLSRV_SVG WHERE server='$server',instance='$instance' ", $mysql)

$da = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($cmd)

$da.InsertCommand = New-Object Mysql.Data.MysqlClient.MySqlCommand( "INSERT INTO SQLSRV_SVG (SERVER,INSTANCE,BASE,TAG,DESCRIPTION,DATESTART,DATEEND,TYPE,SIZE,COMPRESSED_SIZE) VALUES (@server,@instance,@database_name,@name,@description,@backup_start_date,@backup_finish_date,@type,@backup_size,@compressed_backup_size)" , $mysql)

$mp = New-Object ('Mysql.Data.MysqlClient.MySqlParameter')( "@id" , [Mysql.Data.MysqlClient.MySqlDbType]::VarChar , 15 , "id" )

the last line is the one who goes wrong...

thank you !

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>