public DBManager(string ConStringName) { DataBaseConfig dbConfig = new DataBaseConfig(ConStringName); strConnection = dbConfig.ConnectionString; string strProvider = dbConfig.DBProvider.ToString().ToLower(); switch (strProvider) { case "sqlserver": providerType = DataProvider.SqlServer; break; // case "oracle": // providerType = DataProvider.Oracle; // break; case "odbc": providerType = DataProvider.Odbc; break; case "oledb": providerType = DataProvider.OleDb; break; } }
public void InsertVarbinary(byte[] image, string query) { DataBaseConfig dbConfig = new DataBaseConfig(); using (var conn = new SqlConnection(dbConfig.ConnectionString)) using (var cmd = new SqlCommand(query, conn)) { conn.Open(); var param = new SqlParameter("@imagecolumn", SqlDbType.Binary) { // here goes your binary data (make sure it's correct) Value = image }; cmd.Parameters.Add(param); int rowsAffected = cmd.ExecuteNonQuery(); // do your other magic ... } }