我想使用C++查詢從SQL數據庫(SQL Server Enterprise)的列中選擇所有二進制數據。我不確定二進制數據中有什麼,它只是說。 我想這(它被傳遞到我從關學)老實說,我不是100%的明白在某些部分的代碼,因爲我評論):<Binary> in sql
SqlConnection^ cn = gcnew SqlConnection();
SqlCommand^ cmd;
SqlDataAdapter^ da;
DataTable^ dt;
cn->ConnectionString = "Server = localhost; Database=portable; User ID = glitch; Pwd = 1234";
cn->Open();
cmd=gcnew SqlCommand("SELECT BinaryColumn FROM RawData", cn);
da = gcnew SqlDataAdapter(cmd);
dt = gcnew DataTable("BinaryTemp"); //I'm confused about this piece of code, is it supposed to create a new table in the database or a temp one in the code?
da->Fill(dt);
for(int i = 0; i < dt->Rows->Count-1; i++)
{
String^ value_string;
value_string=dt->Rows[i]->ToString();
Console::WriteLine(value_string);
}
cn->Close();
Console::ReadLine();
但它只返回了很多「的System.Data.DataRow」。
有人可以幫助我嗎?
(我需要把它變成一個矩陣的形式我提取二進制數據之後,因此,如果任何人都可以提供一部分幫助爲好,它會不勝感激!)
嘗試使用預備函數或將數據庫視爲I/O流。 –
我編輯過,所以它現在有它的代碼。 @ThomasMatthews你能給我一個例子嗎?或者給我一個更詳細的鏈接? – theGlitch