This is my updated question..
When I try to execute some sql file in a database using c#, I am getting the error as shown below:
My c# code is like:
if (comboBox1.SelectedItem.ToString() == "master" && comboBox2.SelectedItem.ToString() == "master.sql")
{
oConnection.Open();
Server server = new Server(new ServerConnection(oConnection));
if (MessageBox.Show("Execute " + comboBox2.SelectedItem.ToString() + " in the database " + comboBox1.SelectedItem.ToString() + " ?", "Execute?", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
var output = server.ConnectionContext.ExecuteNonQuery(@"D:\Testpgm\master.sql");
if (!output.Equals(0))
{
try
{
MessageBox.Show(comboBox2.SelectedItem.ToString() + " executed successfully in " + comboBox1.SelectedItem.ToString() + " database");
}
catch (Exception exc)
{
MessageBox.Show("Script Execution Failed,"+exc);
}
}
}
else
{
MessageBox.Show("Execution cancelled by the user");
}
else
{
MessageBox.Show("Either the database or the sql script file selected is wrong!!");
}
Can anyone point out why this happens? I have tried almost all the things I found while googling, but unlucky to get what I expected..
I have also tried like adding binding redirect to my app.config since I could find "microsoft.sqlserver.batchparser.dll" version as 10.0.0.0 inside c:\windows\assembly and my c# application looks for the version 9.0.242.0, which again doesnt seems to be working. The code i used is:
<runtime>
<assemblyBinding xmlns="urn:schemas=microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="microsoft.sqlserver.batchparser" publicKeyToken="89845dcd8080cc91" culture="neutral"/>
<bindingRedirect oldVersion="9.0.242.0" newVersion="10.0.0.0"/>
<publisherPolicy apply="no"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Any help would be really appreciated..