0

Okay. I'm at wit's end and haven't found a posting that addresses my problem completely. I'm new to C# and I'm unfamiliar with databases. What I do know is I must output a data file into a 'native' format (instead of ASCII which is why I assume I must use BCP) and when I run my code, no files are created (and when I do create a file before export, no data is exported to the file).

So, here is my C# code

SqlConnection myConn = new SqlConnection("server=localhost\\....;Trusted_Connection=yes;database=...;");
.....
string sp_config = "exec sp_configure 'show advanced options', 1";
command = new SqlCommand(sp_config, myConn);
command.ExecuteNonQuery();

sp_config = "reconfigure";
command = new SqlCommand(sp_config, myConn);
command.ExecuteNonQuery();

sp_config = "exec sp_configure 'xp_cmdShell', 1";
command = new SqlCommand(sp_config, myConn);
command.ExecuteNonQuery();

string bcp_command = "exec xp_cmdShell 'bcp REF_JDLM_DB.." +
                     table_name + " out " + m_destFolder + "\\" + table_name + "-n.dat -n -T'";
command = new SqlCommand(bcp_command, myConn);
command.ExecuteNonQuery();
myConn.Close();

Everything 'appears' to run find but none of the '-n.dat' files are exported. I'm open to any suggestions that allow me to generate files in the 'native' format.

4

0 に答える 0