Romanovskaya Гость
|
Добавлено: Пт Мар 29 2002 13:35 Заголовок сообщения: return |
|
|
Zdravo! U meny est' takoj kod, kotorij normaljno vidaet na pechatj i OutBuffer i OutBuffer1(chto odno i toze), a kak sdelatj prosto funkciu - ne Main, chtobi ona v konce : return, a potom byte[] iz etih bufferov, ili kak f(out buffer), i bufer=OutBuffer?(Chto-to nichego ne poluchaetsja tolkovogo) Zaranee, spasibo/ Poka using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using System.IO;
namespace SelectByte__FromSQL { public class Class1 { const string MyURL ="http://localhost/SsmWebGui/Images/55.wbmp";
public static void Main() { SqlConnection nwindConn = new SqlConnection("Data Source=(local);Integrated Security=SSPI;Initial Catalog=IMG"); string selectStr ="SELECT Picture, LengthPic FROM Slika2 WHERE URLImg = @MyURL"; nwindConn.Open(); SqlCommand selectCMD = new SqlCommand(selectStr, nwindConn); selectCMD.Parameters.Add("@MyURL", SqlDbType.VarChar, 255).Value = MyURL; SqlInt32 anLengthPic; SqlBinary myBinary;
SqlDataReader myReader = selectCMD.ExecuteReader(); while (myReader.Read()) { string myDataType = myReader.GetDataTypeName(0);
myBinary = myReader.GetSqlBinary(0); anLengthPic =myReader.GetInt32(1); byte[] anBuffer = myBinary.Value; Console.WriteLine("myDataType: {0}.", myDataType ); Console.WriteLine("GetSqlBinary: {0}.", myBinary); Console.WriteLine("LengthPic: {0}.", anLengthPic);
MemoryStream ms = new MemoryStream(anBuffer); int BinArr_size; BinArr_size = (int)anLengthPic; byte[] OutBuffer = new byte[BinArr_size]; BinaryReader br = new BinaryReader(ms); int[] myIntArr = new int[BinArr_size]; string[] myStringArr = new string[BinArr_size];
for(int i=0; i |
|